尝试使用带有SUDS的Python将SOAP调用置于Cisco AXL接口。
拥有以下测试代码:
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的帮助将不胜感激。
答案 0 :(得分:0)
您的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地址?