xml - Linux,Curl,发送没有 xml 文件的 -X POST
问题描述
我在 Linux 中有一个带有 curl 的 -X POST 的小 sh 脚本:
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 命令。
中间人.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'
有任何想法吗?
EDIT1:我只想使用 ManInTheMiddle.xml 处理中间步骤,以便服务器直接获取到导入文件 (\serverip\script.xml) 的链接。
EDIT2:使用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")
谢谢你...
解决方案
$() 进行救援,替换
--data @\u\ManInTheMiddle.xml
和
--data-raw "$(curl --silent \\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"" --data-raw "$(curl --silent \\serverip\script.xml)" | grep -o 'true\|false'
请注意,我知道 $() 的可移植性如何,例如它肯定不能在微软的 cmd.exe 上运行,但至少它可以在 bash 上运行
推荐阅读
- hibernate - 使用关系数据库中的键值结构进行存储设置
- angular - Chrome 的撤消功能未注册下拉选择
- javascript - jQuery 最大调用堆栈大小超出,专注于下一个输入字段
- laravel - Laravel 将所有类型的错误重定向到自定义视图
- angular - 离子/角度问题找不到模块'./fs'
- javascript - PHP - ParseGeoPoint 上的 Parse SDK 查询无法正常工作
- sql-server - 如何使用点到站点连接 (P2S) 从我的笔记本电脑连接到 VNet 中的 Azure Sql 托管实例?
- html - 可重复使用的响应式 VR(垂直规则)HTML & CSS
- android - 意外的 Gradle 警告 + 代码编辑器故障
- javascript - 如何从特定元素中获取具有相似类名的项目的某些属性的值