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?
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: