Python调用WebService出错,求解决

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
from suds import WebFault
from suds.client import Client
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDoctor
imp = Import('http://www.w3.org/2001/XMLSchema')
imp.filter.add('http://WebXml.com.cn/')
doctor = ImportDoctor(imp)
url = 'http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?WSDL'
client = Client(url,doctor=doctor)
print (client)
print (client.service.getWeather('58367'))

 

运行结果如下:

DEBUG:suds.wsdl:reading wsdl at: http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?WSDL ...
DEBUG:suds.wsdl:binding: "WeatherWSHttpGet" not a soap binding
DEBUG:suds.wsdl:binding: "WeatherWSHttpPost" not a soap binding
DEBUG:suds.wsdl:binding "WeatherWSHttpGet" - not a soap, discarded
DEBUG:suds.wsdl:binding "WeatherWSHttpPost" - not a soap, discarded
Traceback (most recent call last):
  File "E:\python project\Python_WebService\src\WebServie.py", line 19, in <module>
    client = Client(url,doctor=doctor)
  File "build\bdist.win32\egg\suds\client.py", line 112, in __init__
  File "build\bdist.win32\egg\suds\reader.py", line 152, in open
  File "build\bdist.win32\egg\suds\wsdl.py", line 159, in __init__
  File "build\bdist.win32\egg\suds\wsdl.py", line 220, in build_schema
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 93, in load
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 305, in open_imports
  File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 542, in open
  File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 563, in download
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 397, in instance
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 226, in __init__
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 305, in open_imports
  File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 542, in open
  File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 560, in download
  File "build\bdist.win32\egg\suds\reader.py", line 79, in open
  File "build\bdist.win32\egg\suds\reader.py", line 95, in download
  File "build\bdist.win32\egg\suds\transport\https.py", line 60, in open
  File "build\bdist.win32\egg\suds\transport\http.py", line 62, in open
  File "build\bdist.win32\egg\suds\transport\http.py", line 118, in u2open
  File "C:\Python27\lib\urllib2.py", line 394, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 412, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1199, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python27\lib\urllib2.py", line 1170, in do_open
    r = h.getresponse(buffering=True)
  File "C:\Python27\lib\httplib.py", line 1027, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 371, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

你可能感兴趣的:(webservice)