我正在尝试使用suds python包发送soap请求,如下所示:
from suds.client import Client
WSDL_URL = 'file:/home/Documents/soap/getttt.wsdl'
client = Client(WSDL_URL, cache=None)
result = client.service.GET_TTT(H_ID="01",
TTT_ID="44825955",
VERSION_DATE="2010-12-01",
ACC="B9800B4930543BC4FB305124EDFF7846")
print result
使用带有http uri的简单wsdl可以正常工作,但是我需要使用文件协议加载这个wsdl,这个wsdl要复杂得多。它导入xsd文件,如下所示:
<types>
<xsd:schema>
<xsd:import schemaLocation="GET_TTT.xsd" namespace="http://example.com"/>
<xsd:import schemaLocation="TTT_TABLES.xsd" namespace="http://example.com"/>
</xsd:schema>
</types>
此错误消息失败:
File "suds_client.py", line 17, in <module>
ACC="B9800B4930543BC4FB305124EDFF7846")
File "python2.7/site-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "python2.7/site-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "python2.7/site-packages/suds/client.py", line 637, in send
reply = transport.send(request)
File "python2.7/site-packages/suds/transport/https.py", line 64, in send
return HttpTransport.send(self, request)
File "python2.7/site-packages/suds/transport/http.py", line 77, in send
fp = self.u2open(u2request)
File "python2.7/site-packages/suds/transport/http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
任何想法如何调试这个?我是否需要使用ImportDoctor来加载xsd文件或者是否自动加载它们?如果我这样做,那么如何加载所有的xsd文件? 我能够使用名为soapUI的软件从该wsdl发送请求。 感谢
答案 0 :(得分:0)
如果我只是使用字符串作为参数,它会抱怨参数并说
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
看着:
<xs:complexType name="T_GET_TTT">
<xs:attribute name="HES_ID" type="com:hesHesID" use="required"/>
<xs:attribute name="TTT_ID" type="xs:string" use="required"/>
<xs:attribute name="VERSION_DATE" type="xs:date" use="required"/>
<xs:attribute name="ACC" type="xs:hexBinary" use="required"/>
</xs:complexType>
然后我决定使用从医生那里导入xml模式的正确类型:
imp = Import('http://www.w3.org/2001/XMLSchema')
d = ImportDoctor(imp)
imp.filter.add('http://aa')
client = Client(WSDL_URL, cache=None, doctor=d)
print client
client.factory.create('xs:string')
我的print命令显示我有xs:string类型: 但是我得到了这个错误:
例外:前缀(xs)未解决
为什么它认为xs不是前缀而是类型名称的一部分的任何想法?