Hi, all:
These days I have been doing something about python webservice. Suds, as a client-end, it's good.
Now, ask a question I encounter with about suds:
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
Hi, have you tried using import doctors? https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs
Regards, András Veres-Szentkirályi
2011. december 6. kedd 14:38:51 dátummal 贾晓磊 ezt írta:
Hi, all:
These days I have been doing something about python webservice. Suds, as a client-end, it's good.
Now, ask a question I encounter with about suds:
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/schem a.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/schem a.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/sxbas ic.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/sxbas ic.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/schem a.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/schem a.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/schem a.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/sxbas ic.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/sxbas ic.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/parse r.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
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
??? wrote at 2011-12-7 13:59 +0800:
... 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:
... Traceback (most recent call last): ... 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)
The traceback indicates a bad reply from the remote web server: the response in not a valid HTTP response.
This does not look like a client problem (at least not completely a client problem).
Should the problem be reproducible, then the most likely cause would be some error in the WSDL (bad port information) which causes the client to speak to a non HTTP server.
WSDL is complexe. Especially, it allows to specify different sets of ports. If the concrete WSDL uses multiple ports, clients may choose different ports unless the port is specified explicitely in the call. Maybe, "suds" is using a broken port definition while other clients use another correct port definition.
Note also that "suds" does not (yet) support "SOAP 1.2" (unlike the Java/.Net soap clients). Check whether your WSDL defines a "SOAP 1.1" port and in this case, use this one.
-- Dieter
Hi, Dieter:
Thanks for your replay.
1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/%22%3E <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" # soaplib_server.py import soaplib from soaplib.core.service import soap from soaplib.core.service import rpc, DefinitionBase from soaplib.core.model.primitive import String, Integer from soaplib.core.server import wsgi from soaplib.core.model.clazz import Array from soaplib.core import Application class HelloWorldService(DefinitionBase):
@soap(String,Integer,_returns=Array(String)) def say_hello(self,name,times): results = [] for i in range(0,times): results.append('Hello, %s'%name) return results
if __name__=='__main__': print 'server begin running...' try: from wsgiref.simple_server import make_server soap_application = Application([HelloWorldService], 'tns')
wsgi_application = wsgi.Application(soap_application) server = make_server('localhost', 7789, wsgi_application) server.serve_forever() except ImportError: print "Error: example server code requires Python >= 2.5"
# suds.py import suds def test_soaplib():
url = "http://localhost:7789/?wsdl" client = suds.client.Client(url,cache=None) print 'client', client output = client.service.say_hello('jia',3) print 'output', output
when you invoke sus.py , it takes much time and a long time later returns the right result ”output (stringArray){ string[] = "Hello, jia", "Hello, jia", "Hello, jia", } “ Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): File "suds_client.py", line 774, in <module> test_soaplib() File "suds_client.py", line 627, in test_soaplib client = suds.client.Client(url,cache=None) 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)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
Thanks for your spirit and time.
-- Jia Xiaolei
On Wed, Dec 7, 2011 at 3:17 PM, Dieter Maurer dieter@handshake.de wrote:
??? wrote at 2011-12-7 13:59 +0800:
... 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:
... Traceback (most recent call last): ... 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)
The traceback indicates a bad reply from the remote web server: the response in not a valid HTTP response.
This does not look like a client problem (at least not completely a client problem).
Should the problem be reproducible, then the most likely cause would be some error in the WSDL (bad port information) which causes the client to speak to a non HTTP server.
WSDL is complexe. Especially, it allows to specify different sets of ports. If the concrete WSDL uses multiple ports, clients may choose different ports unless the port is specified explicitely in the call. Maybe, "suds" is using a broken port definition while other clients use another correct port definition.
Note also that "suds" does not (yet) support "SOAP 1.2" (unlike the Java/.Net soap clients). Check whether your WSDL defines a "SOAP 1.1" port and in this case, use this one.
-- Dieter
贾晓磊 wrote at 2011-12-7 15:38 +0800:
... 1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/%22%3E <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
This tells us (only), that namespace prefixes are defined for both "SOAP" (1.1) as well as "SOAP1.2".
The WSDL may define two different ports, one destined for "SOAP" clients another one for "SOAP1.2" clients. In such a case, ensure that "suds" is using the port for "SOAP" clients.
The "suds" documentation tells you how to specify the use of a specific port.
In the cases, where I have seen different ports for "SOAP" and "SOAP1.2" in a WSDL, the port name has distinguished between the two protocols. I have not seen a more formal difference (but I may not have looked with sufficient intensity).
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
I am not idle ;-)
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" ... Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): ... 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)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
When it works sometimes, this excludes a WSDL problem.
Nethertheless, the problem does not look client side -- but server side. You are getting a very low level exception: "httplib" (responsible for the elementary http request/response exchange) complaining about a bad status line (the first line of an HTTP response). The error information (the other part, aside from the traceback) should tell you which "line" has been received. You will find that it does not correspond to the HTTP specification.
To understand in details what happens between a client and a server, a TCP logger (e.g. "etherreal", "wireshark", ...) can be used. It protocols the communication between server and client and you can see precisely which side is responsible for bad behavior.
-- Dieter
We're facing the same issue with suds & soaplib..
we've ended up with a solution that we're using FileCache for suds so after implementing caching suds side, we're facing BadStatusLine problem very rarely...
On Wed, Dec 7, 2011 at 1:32 PM, Dieter Maurer dieter@handshake.de wrote:
贾晓磊 wrote at 2011-12-7 15:38 +0800:
... 1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/
">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
This tells us (only), that namespace prefixes are defined for both "SOAP" (1.1) as well as "SOAP1.2".
The WSDL may define two different ports, one destined for "SOAP" clients another one for "SOAP1.2" clients. In such a case, ensure that "suds" is using the port for "SOAP" clients.
The "suds" documentation tells you how to specify the use of a specific port.
In the cases, where I have seen different ports for "SOAP" and "SOAP1.2" in a WSDL, the port name has distinguished between the two protocols. I have not seen a more formal difference (but I may not have looked with sufficient intensity).
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
I am not idle ;-)
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" ... Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): ... 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)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
When it works sometimes, this excludes a WSDL problem.
Nethertheless, the problem does not look client side -- but server side. You are getting a very low level exception: "httplib" (responsible for the elementary http request/response exchange) complaining about a bad status line (the first line of an HTTP response). The error information (the other part, aside from the traceback) should tell you which "line" has been received. You will find that it does not correspond to the HTTP specification.
To understand in details what happens between a client and a server, a TCP logger (e.g. "etherreal", "wireshark", ...) can be used. It protocols the communication between server and client and you can see precisely which side is responsible for bad behavior.
-- Dieter _______________________________________________ Soap mailing list Soap@python.org http://mail.python.org/mailman/listinfo/soap
We're facing the same issue with suds & soaplib..
we've ended up with a solution that we're using FileCache for suds so after implementing caching suds side, we're facing BadStatusLine problem very rarely...
Thanks for the feedback ! Two question: :) 1: do you mean :
client = suds.client.Client(url,cache=None) ==> client = suds.client.Client(url)
or:
from suds.transport.cache import FileCache mycache = FileCache(days=90) mytransport = MyTransport(cache=mycache)
#NOTE: In fact, set cache did not solve the problem at all. Besides, if remote server makes some change, the cache of client is terrible.
2: Now, what's the server-side you are using? soaplib? Just a advice, tornadows is pretty good. Maybe you have never heard of tornadows, but you must hear of tornado of facebook. So, if pleasure, do some study about tornadows.
some useful link,hope they are helpful to you: https://github.com/rancavil/tornado-webservices/wiki/Python-Web-Services-wit... http://innovaser.cl/innovaser.php
-- Jia Xiaolei
Thanks for your replay.
Sorry for the word "idle". In fact, I am a Chinese, who live in Beijing City, China. Shamed for the terrible english. If we talk a man wih free time, which word should we use? idle, free, leisure,or something else? :)
Okay, last two question: 1: I am a novice to soap, absolutely a newbie. Last week I began to develop Java Axis2 webservice and Python webservice. In python, the server-side use tornadows(tornado web service). They work together well, at least, I have never meet. "The "suds" documentation tells you how to specify the use of a specific port." In fact, I did not know how to specific port in suds. Some helps to me? :)
2: Have you once did something about Java axis2 client? I try to invoke a webservice develped by tornadows using axis2-client, but failed. I provided server-side, client-side and wsdl as follows. If leisure and pleasrue, hava a glance.
# server: import logging
import tornado.httpserver import tornado.ioloop import tornado.web from tornadows import soaphandler from tornadows import webservices from tornadows import xmltypes from tornadows.soaphandler import webservice from tornado.options import define, options
define('mode', default='deploy') define('port', type=int, default=8000) options['logging'].set('warning')
class SMSService(soaphandler.SoapHandler):
@webservice(_params=xmltypes.Integer,_returns=xmltypes.Integer) def getPrice(self,a): return 1987
if __name__ == '__main__': service = [('SMSService',SMSService)] app = webservices.WebService(service) ws = tornado.httpserver.HTTPServer(app)
ws.listen(options.port) logging.warn("SMSService running on: localhost:%d", options.port) tornado.ioloop.IOLoop.instance().start()
# client: package client;
import javax.xml.namespace.QName; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.rpc.client.RPCServiceClient;
public class client_for_python {
public static void main(String[] args) throws Exception {
// step 1: 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); // step 2: 指定调用WebService的URL // url for python String url2 = "http://172.16.2.46:8000/SMSService"; EndpointReference targetEPR = new EndpointReference(url2); options.setTo(targetEPR); // step 3: 指定getGreeting方法的参数值 // step 5-6: (similiar whit // it!)下面是调用getPrice方法的代码,这些代码与调用getGreeting方法的代码类似 Class[] classes = new Class[] { int.class }; QName opAddEntry = new QName( "http://172.16.2.46:8000/SMSService/getPrice"); System.out.println(serviceClient.invokeBlocking(opAddEntry, new Object[] {1}, classes)[0]); } }
## the prolem: no response and server-side get no data
#wsdl:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://127.0.1.1:8000/SMSService/getPrice" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SMSService" targetNamespace="http://127.0.1.1:8000/SMSService/getPrice%22%3E wsdl:types <xsd:schema targetNamespace="http://127.0.1.1:8000/SMSService/getPrice%22%3E <xsd:complexType name="paramsTypes"> xsd:sequence <xsd:element name="a" type="xsd:integer"/> </xsd:sequence> </xsd:complexType> <xsd:element name="params" type="tns:paramsTypes"/> <xsd:element name="returns" type="xsd:integer"/> </xsd:schema> </wsdl:types> <wsdl:message name="SMSServiceRequest"> <wsdl:part element="tns:params" name="parameters"/> </wsdl:message> <wsdl:message name="SMSServiceResponse"> <wsdl:part element="tns:returns" name="parameters"/> </wsdl:message> <wsdl:portType name="SMSServicePortType"> <wsdl:operation name="getPrice"> <wsdl:input message="tns:SMSServiceRequest"/> <wsdl:output message="tns:SMSServiceResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SMSServiceBinding" type="tns:SMSServicePortType"> <soap:binding style="document" transport=" http://schemas.xmlsoap.org/soap/http%22/%3E <wsdl:operation name="getPrice"> <soap:operation soapAction="http://127.0.1.1:8000/SMSService" style="document"/> wsdl:input <soap:body use="literal"/> </wsdl:input> wsdl:output <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SMSService"> <wsdl:port binding="tns:SMSServiceBinding" name="SMSServicePort"> <soap:address location="http://127.0.1.1:8000/SMSService%22/%3E </wsdl:port> </wsdl:service> </wsdl:definitions>
Thanks !
-- Jia Xiaolei
On Wed, Dec 7, 2011 at 4:02 PM, Dieter Maurer dieter@handshake.de wrote:
贾晓磊 wrote at 2011-12-7 15:38 +0800:
... 1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/
">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
This tells us (only), that namespace prefixes are defined for both "SOAP" (1.1) as well as "SOAP1.2".
The WSDL may define two different ports, one destined for "SOAP" clients another one for "SOAP1.2" clients. In such a case, ensure that "suds" is using the port for "SOAP" clients.
The "suds" documentation tells you how to specify the use of a specific port.
In the cases, where I have seen different ports for "SOAP" and "SOAP1.2" in a WSDL, the port name has distinguished between the two protocols. I have not seen a more formal difference (but I may not have looked with sufficient intensity).
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
I am not idle ;-)
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" ... Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): ... 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)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
When it works sometimes, this excludes a WSDL problem.
Nethertheless, the problem does not look client side -- but server side. You are getting a very low level exception: "httplib" (responsible for the elementary http request/response exchange) complaining about a bad status line (the first line of an HTTP response). The error information (the other part, aside from the traceback) should tell you which "line" has been received. You will find that it does not correspond to the HTTP specification.
To understand in details what happens between a client and a server, a TCP logger (e.g. "etherreal", "wireshark", ...) can be used. It protocols the communication between server and client and you can see precisely which side is responsible for bad behavior.
-- Dieter
贾晓磊 wrote at 2011-12-7 16:40 +0800:
... "The "suds" documentation tells you how to specify the use of a specific port." In fact, I did not know how to specific port in suds.
I know that it is in the documentation. But, I will not read for you ;-)
-- Dieter
"The "suds" documentation tells you how to specify the use of a specific
port." In fact, I did not know how to specific port in suds.
I know that it is in the documentation. But, I will not read for you ;-)
okay, thanks all the same!
I will read it myself. Thanks!
-- Jia Xiaolei
Hi, On my side, your HelloWorldService sample works well, client takes 30s to get the result so it is slow.
If you change: client = suds.client.Client(url,cache=None) -> client = suds.client.Client(url) The caching mechanism avoids to rebuild the cache, and calls are much faster.
By adding: import logging logging.basicConfig(level=logging.INFO) #logging.getLogger('suds.client').setLevel(logging.DEBUG) logging.getLogger('suds.transport').setLevel(logging.DEBUG) One can have information on communications while building "cache": time python suds_client.py DEBUG:suds.transport.http:opening (http://localhost:7789/?wsdl) DEBUG:suds.transport.http:opening (http://www.w3.org/2001/XMLSchema.xsd) DEBUG:suds.transport.http:opening (http://www.w3.org/2001/xml.xsd) client ...
Calls to http://www.w3.org/2001/xml.xsd looks like to be quite long. time curl http://www.w3.org/2001/xml.xsd real 0m30.494s user 0m0.004s sys 0m0.000s
This show the 30s are lost in this call
Hoping it can help
On Wed, Dec 7, 2011 at 8:38 AM, 贾晓磊 jiaxiaolei19871112@gmail.com wrote:
Hi, Dieter:
Thanks for your replay.
1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/%22%3E <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" # soaplib_server.py import soaplib from soaplib.core.service import soap from soaplib.core.service import rpc, DefinitionBase from soaplib.core.model.primitive import String, Integer from soaplib.core.server import wsgi from soaplib.core.model.clazz import Array from soaplib.core import Application class HelloWorldService(DefinitionBase):
@soap(String,Integer,_returns=Array(String)) def say_hello(self,name,times): results = [] for i in range(0,times): results.append('Hello, %s'%name) return results
if __name__=='__main__': print 'server begin running...' try: from wsgiref.simple_server import make_server soap_application = Application([HelloWorldService], 'tns')
wsgi_application = wsgi.Application(soap_application) server = make_server('localhost', 7789, wsgi_application) server.serve_forever() except ImportError: print "Error: example server code requires Python >= 2.5"
# suds.py import suds def test_soaplib():
url = "http://localhost:7789/?wsdl" client = suds.client.Client(url,cache=None) print 'client', client output = client.service.say_hello('jia',3) print 'output', output
when you invoke sus.py , it takes much time and a long time later returns the right result ”output (stringArray){ string[] = "Hello, jia", "Hello, jia", "Hello, jia", } “ Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): File "suds_client.py", line 774, in <module> test_soaplib() File "suds_client.py", line 627, in test_soaplib client = suds.client.Client(url,cache=None) 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)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
Thanks for your spirit and time.
-- Jia Xiaolei
On Wed, Dec 7, 2011 at 3:17 PM, Dieter Maurer dieter@handshake.de wrote:
??? wrote at 2011-12-7 13:59 +0800:
... 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:
... Traceback (most recent call last): ... 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)
The traceback indicates a bad reply from the remote web server: the response in not a valid HTTP response.
This does not look like a client problem (at least not completely a client problem).
Should the problem be reproducible, then the most likely cause would be some error in the WSDL (bad port information) which causes the client to speak to a non HTTP server.
WSDL is complexe. Especially, it allows to specify different sets of ports. If the concrete WSDL uses multiple ports, clients may choose different ports unless the port is specified explicitely in the call. Maybe, "suds" is using a broken port definition while other clients use another correct port definition.
Note also that "suds" does not (yet) support "SOAP 1.2" (unlike the Java/.Net soap clients). Check whether your WSDL defines a "SOAP 1.1" port and in this case, use this one.
-- Dieter
-- NAME: 贾晓磊/Jia Xiaolei MOBILE: 13011292217 QQ: 281304051 MICRO-BLOG: http://weibo.com/2183890715 GMAIL: jiaxiaolei19871112@gmail.com gmail%3Ajiaxiaolei19871112@gmail.com
Cloud Services Checklist: Pricing and Packaging Optimization This white paper is intended to serve as a reference, checklist and point of discussion for anyone considering optimizing the pricing and packaging model of a cloud services business. Read Now! http://www.accelacomm.com/jaw/sfnl/114/51491232/ _______________________________________________ Pywebsvcs-talk mailing list Pywebsvcs-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk Also archived at http://groups.google.com/group/pywebsvcs