【问题标题】:Valid SOAP call not working in Python SUDS有效的 SOAP 调用在 Python SUDS 中不起作用
【发布时间】:2011-01-02 14:32:21
【问题描述】:

尝试使用带有 SUDS 的 Python 向 Cisco AXL 接口发出 SOAP 调用。

有如下测试代码:

from suds.client import Client
from suds.sax.element import Element
wsdl = 'file:///C://Cisco//axlsqltoolkit//schema//8.0//AXLAPI.wsdl'
client = Client(wsdl,username='administrator',password='ABC123')
regionName = Element('name').setText('Default')
region = client.service.getRegion(regionName)

得到以下错误:

DEBUG:suds.client:sending to (https://192.168.1.10:8443/axl/)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.cisco.com/AXL/API/8.0" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:getRegion>
         <name>Default</name>
      </ns0:getRegion>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"CUCM:DB ver=8.0 getRegion"', 'Content-Type': 'text/xml; charset=utf-8'}
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.cisco.com/AXL/API/8.0" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:getRegion>
         <name>Default</name>
      </ns0:getRegion>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Item not valid: The specified  was not found</faultstring><detail><axlError><axlcode>5007</axlcode><axlmessage>Item not valid: The specified  was not found</axlmessage><request>getRegion</request></axlError></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Traceback (most recent call last):
  File "C:\Documents and Settings\Administrator\My Documents\python.py", line 30, in <module>
    region = client.service.getRegion(regionName)
  File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
    result = self.send(soapenv)
  File "build\bdist.win32\egg\suds\client.py", line 649, in send
    result = self.failed(binding, e)
  File "build\bdist.win32\egg\suds\client.py", line 702, in failed
    r, p = binding.get_fault(reply)
  File "build\bdist.win32\egg\suds\bindings\binding.py", line 265, in get_fault
    raise WebFault(p, faultroot)
WebFault: Server raised fault: 'Item not valid: The specified  was not found'

但是,如果我将调试中的确切 soap 调用剪切并粘贴到 soapUI 中并执行,它可以正常工作:

<SOAP-ENV:Envelope xmlns:ns0="http://www.cisco.com/AXL/API/8.0" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:getRegion>
         <name>Default</name>
      </ns0:getRegion>
   </ns1:Body>
</SOAP-ENV:Envelope>

任何关于为什么这不适用于 SUDS 的帮助将不胜感激。

【问题讨论】:

    标签: python soap suds


    【解决方案1】:

    您的 CUCM 的发布者 IP/主机名不在 WSDL 中,因此您需要在客户端中指定它。

    from suds.client import Client
    from suds.sax.element import Element
    wsdl = 'file:///C://Cisco//axlsqltoolkit//schema//8.0//AXLAPI.wsdl'
    client = Client(wsdl, location="https://yourpublisher:8443/axl/",
                    username='administrator',password='ABC123')
    regionName = Element('name').setText('Default')
    region = client.service.getRegion(regionName)
    

    您还需要修补您的 suds,因为 Suds 目前不读取 WSDL 中的选择字段。

    查看以下错误:

    希望对你有帮助


    哎呀,重读这篇文章,您似乎手动编辑了您的 WSDL 并添加了您的 pub 的 IP 地址?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 2011-02-12
      相关资源
      最近更新 更多