Hi,
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/"xmlns: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/"xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/">Maybe it's the fault of soap1.2<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">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.pyimport soaplibfrom soaplib.core.service import soapfrom soaplib.core.service import rpc, DefinitionBasefrom soaplib.core.model.primitive import String, Integerfrom soaplib.core.server import wsgifrom soaplib.core.model.clazz import Arrayfrom soaplib.core import Applicationclass 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 resultsif __name__=='__main__':print 'server begin running...'try:from wsgiref.simple_server import make_serversoap_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.pyimport sudsdef test_soaplib():url = "http://localhost:7789/?wsdl"client = suds.client.Client(url,cache=None)print 'client', clientoutput = client.service.say_hello('jia',3)print 'output', outputwhen 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 minutesTraceback (most recent call last):File "suds_client.py", line 774, in <module>test_soaplib()File "suds_client.py", line 627, in test_soaplibclient = 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_schemaself.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 loadchild.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_importsimported = imp.open()File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 608, in openresult = self.download()File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 628, in downloadreturn 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 instancereturn 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_importsimported = imp.open()File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 608, in openresult = self.download()File "/usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/xsd/sxbasic.py", line 626, in downloadroot = 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 parsefp = 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 openreturn 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 openfp = 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 __openreturn self.urlopener.open(u2request)File "/usr/lib/python2.6/urllib2.py", line 391, in openresponse = 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_chainresult = func(*args)File "/usr/lib/python2.6/urllib2.py", line 1161, in http_openreturn self.do_open(httplib.HTTPConnection, req)File "/usr/lib/python2.6/urllib2.py", line 1134, in do_openr = h.getresponse()File "/usr/lib/python2.6/httplib.py", line 986, in getresponseresponse.begin()File "/usr/lib/python2.6/httplib.py", line 391, in beginversion, status, reason = self._read_status()File "/usr/lib/python2.6/httplib.py", line 355, in _read_statusraise 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 XiaoleiOn 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_openThe traceback indicates a bad reply from the remote web server:
> 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 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
------------------------------------------------------------------------------
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