有效的 SOAP 调用在 Python SUDS 中不起作用

发布于 2024-10-09 20:45:35 字数 3543 浏览 2 评论 0原文

尝试使用 Python 和 SUDS 对 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'

但是,如果我将调试中的确切肥皂调用剪切并粘贴到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的帮助将不胜感激。

Trying to place SOAP calls to Cisco AXL interface using Python with SUDS.

Have the following test code:

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)

Getting the following error:

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'

If, however, I cut and paste the exact soap call from the debug into soapUI and execute, it works fine:

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

Any assistance as to why this is not working with SUDS would be greatly appreciated.

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

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

发布评论

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

评论(1

假装不在乎 2024-10-16 20:45:35

您的 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 并添加您酒吧的 IP 地址?

Your CUCM's publisher IP/hostname is not in the WSDL, so you will need to specify it in your client.

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)

You will also need to patch your suds as the choice fields in the WSDL are not read by Suds right now.

See the following bug:

Hope this helps


Whoops reread this and it looks like you edit your WSDL manually and added your pub's IP address?

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