本文介绍了无法呼叫使用SOAPpy的web服务方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打电话给使用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:\usr\bin\Python26\lib\site-packages\SOAPpy\Client.py", line 451, in __call__
return self.__r_call(*args, **kw)
File "C:\usr\bin\Python26\lib\site-packages\SOAPpy\Client.py", line 473, in __r_call
self.__hd, self.__ma)
File "C:\usr\bin\Python26\lib\site-packages\SOAPpy\Client.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')
这篇关于无法呼叫使用SOAPpy的web服务方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!