我在 Linux 中有一个小 sh 脚本,用于使用curl 进行 -X POST:
curl -X POST http://serverip:8081/WebServices/WebServiceSQLTestresult.svc?wsdl -H "Content-Type: text/xml; charset="utf-8"" -H "SOAPAction: "http://tempuri.org/IWebServiceSQLTestresult/InsertPruefResultatFromXMLFile"" --data @\u\ManInTheMiddle.xml | grep -o 'true\|false'
这工作正常,但我必须首先编写 ManInTheMiddle.xml,第二步我可以发送curl 命令。
ManInTheMiddle.xml
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<InsertPruefResultatFromXMLFile xmlns="http://tempuri.org/">
<FilePath>\\serverip\script.xml</FilePath>
</InsertPruefResultatFromXMLFile>
</Body>
</Envelope>
有没有办法在没有 xml 文件的情况下做到这一点?直接发送“\serverip\script.xml”
喜欢:
curl -X POST http://serverip:8081/WebServices/WebServiceSQLTestresult.svc?wsdl -H "Content-Type: text/xml; charset="utf-8"" -H "SOAPAction: "http://tempuri.org/IWebServiceSQLTestresult/InsertPruefResultatFromXMLFile"" --d "\\serverip\script.xml" | grep -o 'true\|false'
有什么想法吗?
编辑1: 我只想使用 ManInTheMiddle.xml 处理中间步骤,以便服务器直接获取导入文件 (\serverip\script.xml) 的链接。
编辑2: 使用Python它可以工作:
url = "http://serverip/WebServices/WebServiceSQLTestresult.svc?wsdl"
import suds
import suds.client
client = suds.client.Client(url)
result = client.service.InsertPruefResultatFromXMLFile("\\\\serverip\script.xml")
谢谢...
最佳答案
在文件名路径前使用@:
curl -X POST http://serverip:8081/WebServices/WebServiceSQLTestresult.svc?wsdl -H "Content-Type: text/xml; charset="utf-8"" -H "SOAPAction: "http://tempuri.org/IWebServiceSQLTestresult/InsertPruefResultatFromXMLFile"" -d @"\\serverip\script.xml" | grep -o 'true\|false'
关于xml - Linux,Curl,发送不带 xml 文件的 -X POST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53315983/