使用wget调用Web服务

mat*_*gll 12 web-services wget

我可以使用CURL从Linux命令行调用Web服务.现在我尝试使用wget来调用Web服务,但我总是收到以下错误: 500内部服务器错误.

我使用以下语法:

wget http://<endPoint> --post-file=soapRequest.xml --header="Content-Type: application/soap+xml" --output-document=soapResponse.xml
Run Code Online (Sandbox Code Playgroud)

其中soapRequest.xml包含XML请求(由SoapUI验证).

wget返回的错误是:

Connecting to <host:port>... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2011-12-12 23:18:33 ERROR 500: Internal Server Error.
Run Code Online (Sandbox Code Playgroud)

Eve*_*zon 16

您没有提到您正在使用哪个Web服务器,或者您的URL是如何格式化的,但是要在IIS上调用用.NET编写的Web服务操作,请使用以下语法:

wget的--post文件= soaprequest.xml --header = "内容类型:文本/ xml"的--header = "的SOAPAction:\"的SOAPAction\"" HTTP://server/app/myservice.asmx -O响应.XML

"soapaction"值可以在WSDL中找到,也可以在ASP.NET为myservice.asmx上的操作创建的信息页面中找到.


小智 5

我必须使用 --header="Content-Type: text/xml"