2

我正在尝试使用 suds python 包发送一个肥皂请求,如下所示:

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 发送请求。谢谢

4

1 回答 1

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')

我的打印命令显示我有 xs:string 类型:但我收到此错误:

例外:前缀 (xs) 未解析

任何想法为什么它认为 xs 不是前缀而是类型名称的一部分?

于 2013-09-21T00:18:49.707 回答