如何用Curl 来post xml 数据


因为登陆服务升级,密码策略变更,以前的测试脚本中的用户密码已经不能登陆,试图通过API直接更改密码,一种是直接update,一种是change,使用curl的时候均未成功。

最后索性重新用curl命令创建新的用户,一番摸索下来,注册用户仅支持私有端口。剩下的问题就是如何使用curl来postxml 文件。

经过一番查找,终于找到了curl使用post的命令:

  1. echo '<?xml version …>'|curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register  
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:

 

  1. 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  
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:

 

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?><user>......</user>  
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><user>......</user>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM