如何用Curl 来post xml 数据
2015-07-22 11:46
197 查看
zhuan : http://blog.csdn.net/aust_niuroutang/article/details/7536861
因为登陆服务升级,密码策略变更,以前的测试脚本中的用户密码已经不能登陆,试图通过API直接更改密码,一种是直接update,一种是change,使用curl的时候均未成功。
最后索性重新用curl命令创建新的用户,一番摸索下来,注册用户仅支持私有端口。剩下的问题就是如何使用curl来postxml 文件。
经过一番查找,终于找到了curl使用post的命令:
[java] view
plaincopy
echo '<?xml version …>'|curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register
其中<?xml version …>就是要post的xml 文件,8081是私有端口。
例子:
Request:
[java] view
plaincopy
echo '<?xml version="1.0" encoding="utf-8" ?><user>......</user>'|curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register
Response:
[java] view
plaincopy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><user>......</user>
因为登陆服务升级,密码策略变更,以前的测试脚本中的用户密码已经不能登陆,试图通过API直接更改密码,一种是直接update,一种是change,使用curl的时候均未成功。
最后索性重新用curl命令创建新的用户,一番摸索下来,注册用户仅支持私有端口。剩下的问题就是如何使用curl来postxml 文件。
经过一番查找,终于找到了curl使用post的命令:
[java] view
plaincopy
echo '<?xml version …>'|curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register
其中<?xml version …>就是要post的xml 文件,8081是私有端口。
例子:
Request:
[java] view
plaincopy
echo '<?xml version="1.0" encoding="utf-8" ?><user>......</user>'|curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register
Response:
[java] view
plaincopy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><user>......</user>
相关文章推荐
- 不要用mssoap来调用webservice, 否则等着头大吧
- Android异步处理四:AsyncTask的实现原理
- 安卓天天练练(四)drawable state 属性
- PHP设计模式漫谈之迭代器模式
- Linux下如何查看系统启动时间和运行时间
- maven 报错
- HTTP referer
- SQL根据一个日期,返回1号至当日所有日期
- Android开发常用的10个工具类
- Android异步处理三:Handler+Looper+MessageQueue深入详解
- Spring注解讲解
- makefile知识点01
- C#使用iTextSharp设置PDF所有页面背景图功能实例
- 2048源码分享
- uva 11374 Airport Express (Dijkstra)
- Android异步处理二:使用AsyncTask异步更新UI界面
- Java中从控制台读取输入的方法的总结
- pydev-python 链接mysql数据库(mac系统)
- poj 3984 迷宫问题 bfs输出路径
- php-fpm