如何用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