Cisco AXL updatePhone使用python3、SUD和SOAP请求

Cisco AXL updatePhone使用python3、SUD和SOAP请求,python,suds,cisco,cisco-axl,Python,Suds,Cisco,Cisco Axl,我现在收到了一些针对UCM 11.5测试环境的SOAP请求。但我正在努力解决这个问题:更新手机 import ssl from suds.client import Client ssl._create_default_https_context = ssl._create_unverified_context username = 'Administrator' passwd = 'Password' wsdl_url = 'http://host.domain.com/axlsqltool

我现在收到了一些针对UCM 11.5测试环境的SOAP请求。但我正在努力解决这个问题:更新手机

import ssl
from suds.client import Client

ssl._create_default_https_context = ssl._create_unverified_context
username = 'Administrator'
passwd = 'Password'
wsdl_url = 'http://host.domain.com/axlsqltoolkit/schema/11.5/AXLAPI.wsdl'
service_url = 'https://host.domain.com/axl/'
cucm_server = Client(wsdl_url, location = service_url, username=username, password=passwd)

def UpdatePhoneByName(cucm_server):
    result = cucm_server.service.updatePhone({'name': 'SEP0023331B4DBB','description': 'Haasdfllo'})
    print(result)
    return
UpdatePhoneByName(cucm_server)
我得到以下结果:

suds.TypeNotFound: Type not found: 'name'
我还将包括cucm_服务器的输出,但仅包括updatePhone部分

updatePhone(ns0:String100 name, ns0:XUUID uuid, ns0:UniqueString128 newName, ns0:String128 description, ns0:XFkType callingSearchSpaceName, ns0:XFkType devicePoolName, ns0:XFkType commonDeviceConfigName, ns0:XFkType commonPhoneConfigName, ns0:XNetworkLocation networkLocation, ns0:XFkType locationName, ns0:XFkType mediaResourceListName, ns0:XMOHAudioSourceId networkHoldMohAudioSourceId, ns0:XMOHAudioSourceId userHoldMohAudioSourceId, ns0:XFkType automatedAlternateRoutingCssName, ns0:XFkType aarNeighborhoodName, ns0:XLoadInformation loadInformation, ns0:XVendorConfig vendorConfig, ns0:String128 versionStamp, ns0:boolean traceFlag, ns0:String128 mlppDomainId, ns0:XStatus mlppIndicationStatus, ns0:XPreemption preemption, ns0:XStatus useTrustedRelayPoint, ns0:boolean retryVideoCallAsAudio, ns0:XFkType securityProfileName, ns0:XFkType sipProfileName, ns0:XFkType cgpnTransformationCssName, ns0:boolean useDevicePoolCgpnTransformCss, ns0:XFkType geoLocationName, ns0:XFkType geoLocationFilterName, ns0:boolean sendGeoLocation, ns0:removeLines removeLines, ns0:addLines addLines, ns0:lines lines, ns0:XFkType phoneTemplateName, ns0:speeddials speeddials, ns0:busyLampFields busyLampFields, ns0:XFkType primaryPhoneName, ns0:XStatus ringSettingIdleBlfAudibleAlert, ns0:XStatus ringSettingBusyBlfAudibleAlert, ns0:blfDirectedCallParks blfDirectedCallParks, ns0:addOnModules addOnModules, ns0:XUserLocale userLocale, ns0:XCountry networkLocale, ns0:XInteger idleTimeout, xs:string authenticationUrl, xs:string directoryUrl, xs:string idleUrl, xs:string informationUrl, xs:string messagesUrl, xs:string proxyServerUrl, xs:string servicesUrl, ns0:services services, ns0:XFkType softkeyTemplateName, ns0:XFkType defaultProfileName, ns0:boolean enableExtensionMobility, ns0:XBarge singleButtonBarge, ns0:XStatus joinAcrossLines, ns0:XStatus builtInBridgeStatus, ns0:XStatus callInfoPrivacyStatus, ns0:XStatus hlogStatus, ns0:XFkType ownerUserName, ns0:boolean ignorePresentationIndicators, ns0:XPacketCaptureMode packetCaptureMode, ns0:XInteger packetCaptureDuration, ns0:XFkType subscribeCallingSearchSpaceName, ns0:XFkType rerouteCallingSearchSpaceName, ns0:boolean allowCtiControlFlag, ns0:XFkType presenceGroupName, ns0:boolean unattendedPort, ns0:boolean requireDtmfReception, ns0:boolean rfc2833Disabled, ns0:XCertificateOperation certificateOperation, ns0:XAuthenticationMode authenticationMode, ns0:XKeySize keySize, ns0:XKeyOrder keyOrder, ns0:XECKeySize ecKeySize, ns0:String128 authenticationString, xs:string upgradeFinishTime, ns0:XStatus deviceMobilityMode, ns0:boolean remoteDevice, ns0:XDNDOption dndOption, ns0:XRingSetting dndRingSetting, ns0:boolean dndStatus, ns0:boolean isActive, ns0:XFkType mobilityUserIdName, ns0:XPhonePersonalization phoneSuite, ns0:XPhoneServiceDisplay phoneServiceDisplay, ns0:boolean isProtected, ns0:boolean mtpRequired, ns0:XSIPCodec mtpPreferedCodec, ns0:XFkType dialRulesName, ns0:String50 sshUserId, ns0:String255 sshPwd, ns0:String255 digestUser, ns0:XOutboundCallRollover outboundCallRollover, ns0:boolean hotlineDevice, ns0:String255 secureInformationUrl, ns0:String255 secureDirectoryUrl, ns0:String255 secureMessageUrl, ns0:String255 secureServicesUrl, ns0:String255 secureAuthenticationUrl, ns0:String255 secureIdleUrl, ns0:XStatus alwaysUsePrimeLine, ns0:XStatus alwaysUsePrimeLineForVoiceMessage, ns0:XFkType featureControlPolicy, ns0:XDeviceTrustMode deviceTrustMode, ns0:boolean earlyOfferSupportForVoiceCall, ns0:boolean requireThirdPartyRegistration, ns0:boolean blockIncomingCallsWhenRoaming, xs:string homeNetworkId, ns0:boolean AllowPresentationSharingUsingBfcp, ns0:confidentialAccess confidentialAccess, ns0:boolean requireOffPremiseLocation, ns0:boolean allowiXApplicableMedia, ns0:XFkType cgpnIngressDN, ns0:boolean useDevicePoolCgpnIngressDN, ns0:String128 msisdn, ns0:boolean enableCallRoutingToRdWhenNoneIsActive, ns0:XFkType wifiHotspotProfile, ns0:XFkType wirelessLanProfileGroup, ns0:XFkType elinGroup)
我还尝试了
uuid
\uuid
\u name
但似乎没有任何效果


任何帮助都将不胜感激

您是否检查了WSDL?对吗?它定义了“名称”吗

只是看了一下医生。请将
打印cucm_服务器的输出包含到您的问题中。根据我所看到的,方法采用命名参数,只有一个dict


无论如何,我都没有时间用肥皂水。不久前,我切换到了WSDL,它就像一个符咒一样工作。

您检查了WSDL吗?对吗?它定义了“名称”吗

只是看了一下医生。请将
打印cucm_服务器的输出包含到您的问题中。根据我所看到的,方法采用命名参数,只有一个dict


无论如何,我都没有时间用肥皂水。不久前我换了一种,它很有魅力。

我觉得它的格式是这样的
updatePhone=cucm\u server.service.updatePhone(uuid=uuid,newName=newName,description=description)

我认为格式类似
updatePhone=cucm_server.service.updatePhone(uuid=uuid,newName=newName,description=description)

简短回答:

Dump
suds
,它不受主动支持。改用
zeep

如果您想要
zeep
的工作示例,请参阅:

# -*- coding: utf-8 -*-

from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from requests import Session
from requests.auth import HTTPBasicAuth
import urllib3
from urllib3.exceptions import InsecureRequestWarning


urllib3.disable_warnings(InsecureRequestWarning)

USERNAME = 'administrator'
PASSWORD = 'ciscopsdt'
IP_ADDRESS = "123.123.123.123"
WSDL = 'file://C://path//to//schema//11.5//AXLAPI.wsdl'
BINDING_NAME = "{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
ADDRESS = "https://{ip}:8443/axl/".format(ip=IP_ADDRESS)


def update_phone_by_name(client, name, description):
    return client.updatePhone(**{'name': name, 'description': description})


def get_phone_by_name(client, name):
    return client.getPhone(name=name)


def main():
    session = Session()
    session.verify = False
    session.auth = HTTPBasicAuth(USERNAME, PASSWORD)
    transport = Transport(cache=SqliteCache(), session=session, timeout=60)
    client = Client(wsdl=WSDL, transport=transport)
    axl = client.create_service(BINDING_NAME, ADDRESS)

    update_phone_by_name(axl, "BOTUSER011", "update my description")
    print(get_phone_by_name(axl, "BOTUSER011"))


if __name__ == '__main__':
    main()
但是,如果您必须继续使用肥皂水,以下是使用suds jurko的示例:

# -*- coding: utf-8 -*-

import ssl
from suds.client import Client


ssl._create_default_https_context = ssl._create_unverified_context
username = 'administrator'
password = 'cisco'
wsdl_url = 'file:///C://path//to//schema//current//AXLAPI.wsdl'
service_url = 'https://123.123.123.123:8443/axl/'


def update_phone_by_name(client, name, description):
    return client.service.updatePhone(**{'name': name, 'description': description})


def get_phone_by_name(client, name):
    return client.service.getPhone(name=name)


def main():
    cucm_server = Client(wsdl_url, location=service_url, username=username, password=password)
    print(get_phone_by_name(cucm_server, 'BOTUSER011'))


if __name__ == '__main__':
    main()

如果仔细观察,您会发现您的错误是由于发送了字典,而不是函数中的
**kwargs
“按姓名更新手机”

简短回答:

Dump
suds
,它不受主动支持。改用
zeep

如果您想要
zeep
的工作示例,请参阅:

# -*- coding: utf-8 -*-

from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from requests import Session
from requests.auth import HTTPBasicAuth
import urllib3
from urllib3.exceptions import InsecureRequestWarning


urllib3.disable_warnings(InsecureRequestWarning)

USERNAME = 'administrator'
PASSWORD = 'ciscopsdt'
IP_ADDRESS = "123.123.123.123"
WSDL = 'file://C://path//to//schema//11.5//AXLAPI.wsdl'
BINDING_NAME = "{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
ADDRESS = "https://{ip}:8443/axl/".format(ip=IP_ADDRESS)


def update_phone_by_name(client, name, description):
    return client.updatePhone(**{'name': name, 'description': description})


def get_phone_by_name(client, name):
    return client.getPhone(name=name)


def main():
    session = Session()
    session.verify = False
    session.auth = HTTPBasicAuth(USERNAME, PASSWORD)
    transport = Transport(cache=SqliteCache(), session=session, timeout=60)
    client = Client(wsdl=WSDL, transport=transport)
    axl = client.create_service(BINDING_NAME, ADDRESS)

    update_phone_by_name(axl, "BOTUSER011", "update my description")
    print(get_phone_by_name(axl, "BOTUSER011"))


if __name__ == '__main__':
    main()
但是,如果您必须继续使用肥皂水,以下是使用suds jurko的示例:

# -*- coding: utf-8 -*-

import ssl
from suds.client import Client


ssl._create_default_https_context = ssl._create_unverified_context
username = 'administrator'
password = 'cisco'
wsdl_url = 'file:///C://path//to//schema//current//AXLAPI.wsdl'
service_url = 'https://123.123.123.123:8443/axl/'


def update_phone_by_name(client, name, description):
    return client.service.updatePhone(**{'name': name, 'description': description})


def get_phone_by_name(client, name):
    return client.service.getPhone(name=name)


def main():
    cucm_server = Client(wsdl_url, location=service_url, username=username, password=password)
    print(get_phone_by_name(cucm_server, 'BOTUSER011'))


if __name__ == '__main__':
    main()

如果仔细观察,您会发现您的错误是由于发送了一个字典,而不是函数中的
**kwargs
update\u phone\u by\u name

我使用SoapUI和相同的WSDL成功请求,所以这应该不是问题。我使用SoapUI和相同的WSDL成功请求,所以这应该不是问题。