从Bash脚本发布SOAP动态信封

时间:2014-09-11 17:29:06

标签: xml bash soap sed xsd

我想通过bash发布肥皂信封。

我可以这样做

#curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @request.xml -X POST http://soap.sd.testdomain.com.tr/webservice/test

request.xml

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:tos="http://xx">    
<soapenv:Header/>    
<soapenv:Body>
<tos:createSend soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<customerSend xsi:type="java:CustomerSend" xmlns:java="java:com.deneme.test.model">
<actionId xsi:type="xsd:long"></actionId>
<actionStatus xsi:type="xsd:int">2</actionStatus>
</customerSend>
</tos:createSend>    
</soapenv:Body> 
</soapenv:Envelope>

首次成功后,我想通过从文件中读取数据来发出动态请求,然后请求文件的每一行。

这是我的文件的例子

1; 2; AT-902737;注4

1; 2; AT-902738;注4

我想将AT-902737参数作为actionId传递 和4参数作为actionStatus

我尝试启动脚本,但无法完成:(

#!/bin/sh

while IFS=";", read -r -a input; do

printf "%s\n" "${input[2]}" "${input[4]}"


#sed -i 's#\(<actionId xsi:type="xsd:long">\)*\(</actionId>\)#\1'"${input[2]}"'\2#g' request.xml

#curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @request.xml -X POST http://soap.sd.testdomain.com.tr/webservice/test

我尝试但无法成功,因为$ {input [2]}参数在XML文件中显示为$ {input [2]}。不如AT-902737

0 个答案:

没有答案