在Ubuntu中通过命令行访问SOAP Web服务

时间:2015-02-06 22:04:12

标签: linux web-services curl soap command-line

我有一个SOAP Web服务。我可以从应用程序本身调用服务。但现在我的要求是可以在服务器本身内部调用它。

换句话说,我需要一种从Linux命令行调用此服务的方法。我听说curl命令可以做到。但是我不确定我需要注意什么才能让卷毛工作/

ID: 1
Address: http://localhost:9000/sampleApp/hellome
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:sayHelloWithTime xmlns:ns1="http://hello.sample.com"><ns1:timeOfDay>2015-02-05T00:00:00-05:00</ns1:timeOfDay></ns1:sayHelloWithTime></soap:Body></soap:Envelope>

我不确定curl命令允许调用此Web服务。

1 个答案:

答案 0 :(得分:2)

您可以使用以下命令从linux终端调用Web服务。

curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @your_soap_request.xml -X POST http://localhost:9000/sampleApp/hellome

your_soap_request.xml将用于定义带有必需参数的soap请求消息。相应地更改值。

<强> your_soap_request.xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="XXXXCHANGEXXXXXX">
   <soapenv:Header/>
   <soapenv:Body>
      <impl:methodName>
         <arg0>XXXXXX</arg0>
      </impl:methodName>
   </soapenv:Body>
</soapenv:Envelope>
希望这会对你有所帮助。 如果您有任何疑问,请告诉我

由于