suds 中的“<故障代码>”是什么意思?未映射到消息部分”?

发布于 2024-09-04 04:46:21 字数 1788 浏览 6 评论 0原文

我是第一次使用 suds,并尝试与外部公司托管的服务器进行通信。当我调用服务器上的方法时,我会返回此 XML。

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>

      <faultstring>Can't use string ("") as an ARRAY ref while "strict refs" in use at /vindicia/site_perl/Vindicia/Soap/DocLitUtils.pm line 130.
</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

抛出的异常是这样的:

  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 538, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 602, in invoke
    result = self.send(msg)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 634, in send
    result = self.succeeded(binding, reply.message)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 669, in succeeded
    r, p = binding.get_reply(self.method, reply)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\bindings\binding.py", line 157, in get_reply
    result = self.replycomposite(rtypes, nodes)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\bindings\binding.py", line 227, in replycomposite
    raise Exception(' not mapped to message part' % tag)
Exception: 'faultcode' not mapped to message part

知道为什么 suds 抛出异常吗?关于如何修复它有什么想法吗?

I'm using suds for the first time and trying to communicate with a server hosted by an external company. When I call a method on the server I get this XML back.

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>

      <faultstring>Can't use string ("") as an ARRAY ref while "strict refs" in use at /vindicia/site_perl/Vindicia/Soap/DocLitUtils.pm line 130.
</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

The exception thrown is this:


  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 538, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 602, in invoke
    result = self.send(msg)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 634, in send
    result = self.succeeded(binding, reply.message)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\client.py", line 669, in succeeded
    r, p = binding.get_reply(self.method, reply)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\bindings\binding.py", line 157, in get_reply
    result = self.replycomposite(rtypes, nodes)
  File "C:\Python26\lib\site-packages\suds-0.4-py2.6.egg\suds\bindings\binding.py", line 227, in replycomposite
    raise Exception(' not mapped to message part' % tag)
Exception: 'faultcode' not mapped to message part

Any idea why suds is throwing the exception? Any thoughts on how it could be fixed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗琴音 2024-09-11 04:46:21

我遇到了类似的问题,呼叫成功,并且肥皂水在解析客户端的响应时崩溃。我使用的解决方法是使用 suds 选项返回原始 XML< /a> 然后使用 BeautifulSoup 解析响应。

例子:

client = Client(url)
client.set_options(retxml=True)
soapresp_raw_xml = client.service.submit_func(data)
soup = BeautifulStoneSoup(soapresp_raw_xml)
value_i_want = soup.find('ns:NewSRId')

I had a similar issue where the call was successful, and suds crashed on parsing the response from the client. The workaround I used was to use the suds option to return raw XML and then use BeautifulSoup to parse the response.

Example:

client = Client(url)
client.set_options(retxml=True)
soapresp_raw_xml = client.service.submit_func(data)
soup = BeautifulStoneSoup(soapresp_raw_xml)
value_i_want = soup.find('ns:NewSRId')
演出会有结束 2024-09-11 04:46:21

已经在这里回答:什么是suds 的意思是“未映射到消息部分”?

这个异常实际上意味着 SOAP 服务的答案包含标签 ,而存在于服务的 WSDL 方案中。

请记住,suds 库会缓存 WSDL 方案,这就是如果最近更改 WSDL 方案可能会出现问题的原因。然后,答案与新方案匹配,但由 suds-client 与旧方案进行验证。在这种情况下,rm /tmp/suds/*将为您提供帮助。

Already answered here: What does suds mean by "<faultcode/> not mapped to message part"?

This exception actually means that the answer from SOAP-service contains tag <faultcode>, which doesn't exist in the WSDL-scheme of the service.

Keep in mind that suds library caches the WSDL-scheme, that is why the problem may occur if the WSDL-scheme was changed recently. Then the answers match the new scheme, but are verified by the suds-client with the old one. In this case rm /tmp/suds/* will help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文