Valid SOAP call not working in Python SUDS

不羁的心 提交于 2019-12-25 08:15:37

问题


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.


回答1:


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:

  • https://fedorahosted.org/suds/ticket/332
  • https://fedorahosted.org/suds/ticket/342

Hope this helps


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



来源:https://stackoverflow.com/questions/4578802/valid-soap-call-not-working-in-python-suds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!