使用 wget 调用 Web 服务 [英] Call Web Service using wget
问题描述
我可以使用 CURL 从 Linux 命令行调用 Web 服务.现在我正在尝试使用 wget 来调用 Web 服务,但我总是收到以下错误:500 内部服务器错误.
I'm able to call a web service from Linux command line using CURL. Now I'm tryng to use wget to call a Web Service but I always receive the following error: 500 Internal Server Error.
我使用以下语法:
wget http://<endPoint> --post-file=soapRequest.xml --header="Content-Type: application/soap+xml" --output-document=soapResponse.xml
其中soapRequest.xml 包含XML 请求(由SoapUI 验证).
Where soapRequest.xml contains the XML request (validated by SoapUI).
wget 返回的错误是:
The error returned from wget is:
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.
推荐答案
你没有提到你使用的是哪个 web 服务器,或者你的 URL 是如何格式化的,但是要在 IIS 上调用用 .NET 编写的 web 服务操作,请使用这个语法:
You don't mention which webserver you are using, or how your URL is formatted, but to invoke a web service operation written in .NET on IIS use this syntax:
wget --post-file=soaprequest.xml --header="Content-Type: text/xml" --header="SOAPAction: \"soapaction\"" http://server/app/myservice.asmx -O response.xml
soapaction
"值可以在 WSDL 中找到,也可以在 ASP.NET 为 myservice.asmx
中的操作创建的信息页面上找到.
The "soapaction
" value can be found in the WSDL, or on the information page ASP.NET creates for the operation at myservice.asmx
.
这篇关于使用 wget 调用 Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!