Hi, all:

In fact,I had sent the mail to fedora-suds-list@redhat.com few days ago.While, nobody give a response.Today, I would like some suds users and lovers can give some points. Thank in advance.

These days I have been doing something about python webservice. Suds, as a client-end, it's good.But, a problem puzzled me:

When I try to invoke a remote method getWeather() in the url "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl", it failed. My code and the exception returned are as follows:

# filename: suds.py
import suds
def test_weather():
    from suds.xsd.doctor import ImportDoctor, Import
    imp = Import('http://www.w3.org/2001/XMLSchema')
    d = ImportDoctor(imp)

    url = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl"
    client = suds.client.Client(url,doctor=d,cache=None,xstq=False,faults=False)
    print 'client', client
    a =  10.0
    b = 3.0
    #output1 = client.service.getRegionCountry()
    output = client.service.getWeather(100)
    print 'weatherv', output

# output:

Traceback (most recent call last):
  File "suds_client.py", line 787, in <module>
    test_weather()
  File "suds_client.py", line 739, in test_weather
    client = suds.client.Client(url,doctor=d,cache=None,xstq=False,faults=False)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/client.py", line 109, in __init__
    self.wsdl = Definitions(url, options)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/wsdl.py", line 194, in __init__
    self.build_schema()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/wsdl.py", line 255, in build_schema
    self.schema = container.load()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/schema.py", line 90, in load
    child.open_imports()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/schema.py", line 277, in open_imports
    imported = imp.open()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 608, in open
    result = self.download()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 628, in download
    return self.schema.instance(root, url)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/schema.py", line 367, in instance
    return Schema(root, baseurl, self.options)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/schema.py", line 200, in __init__
    self.open_imports()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/schema.py", line 277, in open_imports
    imported = imp.open()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 608, in open
    result = self.download()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 626, in download
    root = Parser(transport).parse(url=url).root()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/sax/parser.py", line 133, in parse
    fp = self.transport.open(Request(url))
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/https.py", line 69, in open
    return  HttpTransport.open(self, request)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.py", line 69, in open
    fp = self.__open(u2request)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.py", line 107, in __open
    return self.urlopener.open(u2request)
  File "/usr/lib/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 409, in _open
    '_open', req)
 File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 1161, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1134, in do_open
    r = h.getresponse()
  File "/usr/lib/python2.6/httplib.py", line 986, in getresponse
    response.begin()
  File "/usr/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
    raise BadStatusLine(line)

#NOTE: 
1: the url "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" is avaliable, you can click it and see the wsdl.
2: the url is provided  by a corporation in China, in another page (http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?op=getWeather), put a number in the field “theCityCode” and click the butter , you can get a xml file has contains the results. Anyone can have a try!

I like suds and believe it's strong and stable enough. Hope someone can tell me what's the reason it throw exception?
-- Jia Xiaolei




--
NAME: 贾晓磊/Jia Xiaolei
MOBILE: 13011292217
QQ: 281304051
MICRO-BLOG:  http://weibo.com/2183890715
GMAIL: jiaxiaolei19871112@gmail.com