无法呼叫使用SOAPpy的web服务方法方法、SOAPpy、web

由网友(泪干 无息)分享简介:我想打电话给使用SOAPpy的web服务:I am trying to call a webservice using SOAPpy:from SOAPpy import SOAPProxyurl = 'http://www.webservicex.net/WeatherForecast.asmx'server =...

我想打电话给使用SOAPpy的web服务:

I am trying to call a webservice using SOAPpy:

from SOAPpy import SOAPProxy

url = 'http://www.webservicex.net/WeatherForecast.asmx'

server = SOAPProxy(url);
print server.GetWeatherByPlaceName('Dallas');
print server.GetWeatherByZipCode ('33126');

服务器调​​用失败:

The server call fails:

Traceback (most recent call last):
  File "soap_test.py", line 6, in <module>
    print server.GetWeatherByPlaceName('Dallas');
  File "C:usrbinPython26libsite-packagesSOAPpyClient.py", line 451, in __call__
    return self.__r_call(*args, **kw)
  File "C:usrbinPython26libsite-packagesSOAPpyClient.py", line 473, in __r_call
    self.__hd, self.__ma)
  File "C:usrbinPython26libsite-packagesSOAPpyClient.py", line 387, in __call
    raise p
SOAPpy.Types.faultType: <Fault soap:Client: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: GetWeatherByPlaceName.
   at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing): >

我是什么做错了吗?

What am I doing wrong?

推荐答案

随着错误消息的状态,SOAPpy的不添加SOAPAction HTTP头。这就是为什么SOAPpy的不许多服务工作。尝试泡沫,这里是一个工作的例子:

As error message states, SOAPpy doesn't add SOAPAction HTTP header. That's why SOAPpy won't work for many services. Try suds, here is a working example:

from suds.client import Client

url = 'http://www.webservicex.net/WeatherForecast.asmx?WSDL'
client = Client(url)

print client.service.GetWeatherByPlaceName('Dallas')
print client.service.GetWeatherByZipCode ('33126')
阅读全文

相关推荐

最新文章