2008-09-17 61 views

回答

40

發佈的字符串:

curl -d "String to post" "http://www.example.com/target" 

發佈一個文件的內容:

curl -d @soap.xml "http://www.example.com/target" 
+21

通常這頭也是必要的:-H 「內容類型:應用程序/肥皂+ xml的;字符集= UTF-8」 – tokland 2010-09-15 15:14:51

+0

@Luca請注意數據應該是URL編碼的。 – 2008-09-17 14:56:29

+2

獲取`HTTP/1.1 415 Unsupported Media Type`意味着內容類型標題丟失或錯誤。嘗試其中一個在這裏建議(`應用程序/肥皂+ xml`不適用於我,但`text/xml`工作) – Nickolay 2014-06-11 09:27:27

33

對於SOAP 1.2 web服務,我通常使用

curl --header "content-type: application/soap+xml" --data @filetopost.xml http://domain/path 
25

錯誤。 這對我不起作用。

對於我這樣一個原理:

curl -H 'SOAPACTION: "urn:samsung.com:service:MainTVAgent2:1#CheckPIN"' -X POST -H 'Content-type: text/xml' -d @/tmp/pinrequest.xml 192.168.1.5:52235/MainTVServer2/control/MainTVAgent2 
8
curl -H "Content-Type: text/xml; charset=utf-8" \ 
-H "SOAPAction:" \ 
-d @soap.txt -X POST http://someurl