0
我一直在努力讓思科呼叫管理器的AXL與Python協作而不是使用PHP(我在這裏運行時沒有問題),並且一直在遇到問題。我花了好幾個小時的時間來抨擊它,所以我想現在是時候請求外部意見,看看你能否提供任何見解。 我消毒的代碼如下:使用Python Suds和Cisco Axl獲取正確的屬性嵌套
from suds.client import Client
from suds.transport.https import HttpAuthenticated
import logging
logging.basicConfig(level=logging.CRITICAL)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.CRITICAL)
logging.getLogger('suds.xsd.schema').setLevel(logging.CRITICAL)
logging.getLogger('suds.wsdl').setLevel(logging.CRITICAL)
service = 'https://IPADDRESS:PORT/axl/'
wsdl = 'file:///PATH/TO/LOCAL/WSDL/AXLAPI.wsdl'
username = "username"
password = "password"
client = Client(wsdl, location = service, transport = HttpAuthenticated(username = username, password = password))
name = "NAME_DP"
tags = ["regionName"]
print "<THIS IS A LISTDEVICEPOOL REQUEST>"
dp = client.factory.create('ns0:ListDevicePoolReq')
dp.searchCriteria.name = name
dp.returnedTags = tags
result = client.service.listDevicePool(dp)
print "<THIS IS THE RESULT>"
print result
的問題是肥皂輸出最終被:
DEBUG:suds.client:headers = {'SOAPAction': u'"CUCM:DB ver=8.5 listDevicePool"',
'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.5" xmlns:ns1="http:
//schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchem
a-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:listDevicePool>
<searchCriteria>
<searchCriteria>
<name>NAME_DP</name>
</searchCriteria>
<returnedTags>regionName</returnedTags>
</searchCriteria>
</ns0:listDevicePool>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://sc
hemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapen
v:Server</faultcode><faultstring>Usage: Required returnedTags as empty tag or sh
ould contain requested tags</faultstring><detail><axlError><axlcode>5003</axlcod
e><axlmessage>Usage: Required returnedTags as empty tag or should contain reques
ted tags</axlmessage><request>listDevicePool</request></axlError></detail></soap
env:Fault></soapenv:Body></soapenv:Envelope>
Traceback (most recent call last):
File "C:\Users\C53170\Desktop\sudstest\barebones.py", line 39, in <module>
result = client.service.listDevicePool(dp)
File "C:\Python27\lib\site-packages\suds\client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "C:\Python27\lib\site-packages\suds\client.py", line 602, in invoke
result = self.send(soapenv)
File "C:\Python27\lib\site-packages\suds\client.py", line 649, in send
result = self.failed(binding, e)
File "C:\Python27\lib\site-packages\suds\client.py", line 702, in failed
r, p = binding.get_fault(reply)
File "C:\Python27\lib\site-packages\suds\bindings\binding.py", line 265, in ge
t_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Usage: Required returnedTags as empty tag or should contain requested tags'
正如你所看到的,它築巢的一切(包括定義searchCriteria)的searchCriteria屬性裏面,這會導致返回的Tags屬性被視爲searchCriteria的一部分。我無法發現原因,或者確定如何改正原因。這是如何導入wsdl的問題?
如果您需要查看導入的wsdl或xsd文件,請告訴我。它們非常大,而且我無法從這臺計算機上訪問pastebin或google文檔(在工作時被阻止),但我可以找到一些地方將它們扔掉。
非常感謝您的協助!