Python-zeep: zeep assigning "_value_1" when xml tag response includes uuid

Created on 3 Apr 2018  路  7Comments  路  Source: mvantellingen/python-zeep

Overview:

I am getting weird output from zeep for certain xml responses which have uuid's in the xml response tags. zeep appears to place the uuid inside an attribute dict, and then assigns the expected value to _value_1

Here is the xml returned when using SoapUI:
SoapUI Response

Please note the following issue line:
<locationName uuid="{29C5C1C4-8871-4D1E-8394-0B9181E8C54D}">Hub_None</locationName>

This is translated into the following by zeep:

'locationName': {
                '_value_1': 'Hub_None',
                'uuid': '{29C5C1C4-8871-4D1E-8394-0B9181E8C54D}'
            }

I can understand why it is doing this, but is there no better way to handle this?

Here is the full response output from zeep:

{
    'return': {
        'phone': {
            'name': 'BOTUSER011',
            'description': 'update my description',
            'product': 'Cisco Dual Mode for Android',
            'model': 'Cisco Dual Mode for Android',
            'class': 'Phone',
            'protocol': 'SIP',
            'protocolSide': 'User',
            'callingSearchSpaceName': {
                '_value_1': None,
                'uuid': None
            },
            'devicePoolName': {
                '_value_1': 'Default',
                'uuid': '{1B1B9EB6-7803-11D3-BDF0-00108302EAD1}'
            },
            'commonDeviceConfigName': {
                '_value_1': None,
                'uuid': None
            },
            'commonPhoneConfigName': {
                '_value_1': 'Standard Common Phone Profile',
                'uuid': '{AC243D17-98B4-4118-8FEB-5FF2E1B781AC}'
            },
            'networkLocation': 'Use System Default',
            'locationName': {
                '_value_1': 'Hub_None',
                'uuid': '{29C5C1C4-8871-4D1E-8394-0B9181E8C54D}'
            },
            'mediaResourceListName': {
                '_value_1': None,
                'uuid': None
            },
            'networkHoldMohAudioSourceId': None,
            'userHoldMohAudioSourceId': None,
            'automatedAlternateRoutingCssName': {
                '_value_1': None,
                'uuid': None
            },
            'aarNeighborhoodName': {
                '_value_1': None,
                'uuid': None
            },
            'loadInformation': {
                '_value_1': None,
                'special': 'false'
            },
            'vendorConfig': None,
            'versionStamp': '{1522743592-A6DC7BDC-C533-4537-8630-03F0CE4C193E}',
            'traceFlag': 'false',
            'mlppDomainId': None,
            'mlppIndicationStatus': 'Off',
            'preemption': 'Disabled',
            'useTrustedRelayPoint': 'Default',
            'retryVideoCallAsAudio': 'true',
            'securityProfileName': {
                '_value_1': 'Cisco Dual Mode for Android - UDP',
                'uuid': '{3A1DDB1D-CD1E-118D-951E-AFE1AADBAC03}'
            },
            'sipProfileName': {
                '_value_1': 'Standard SIP Profile',
                'uuid': '{FCBC7581-4D8D-48F3-917E-00B09FB39213}'
            },
            'cgpnTransformationCssName': {
                '_value_1': None,
                'uuid': None
            },
            'useDevicePoolCgpnTransformCss': 'true',
            'geoLocationName': {
                '_value_1': None,
                'uuid': None
            },
            'geoLocationFilterName': {
                '_value_1': None,
                'uuid': None
            },
            'sendGeoLocation': 'false',
            'lines': {
                'line': [
                    {
                        'index': 1,
                        'label': None,
                        'display': None,
                        'dirn': {
                            'pattern': '1011',
                            'routePartitionName': {
                                '_value_1': None,
                                'uuid': None
                            },
                            'uuid': '{94EEDC85-CAAB-3AFC-A6DD-BB7F96057AD9}'
                        },
                        'ringSetting': 'Ring',
                        'consecutiveRingSetting': 'Use System Default',
                        'ringSettingIdlePickupAlert': None,
                        'ringSettingActivePickupAlert': None,
                        'displayAscii': None,
                        'e164Mask': None,
                        'dialPlanWizardId': None,
                        'mwlPolicy': 'Use System Policy',
                        'maxNumCalls': 3,
                        'busyTrigger': 2,
                        'callInfoDisplay': {
                            'callerName': 'true',
                            'callerNumber': 'false',
                            'redirectedNumber': 'false',
                            'dialedNumber': 'true'
                        },
                        'recordingProfileName': {
                            '_value_1': None,
                            'uuid': None
                        },
                        'monitoringCssName': {
                            '_value_1': None,
                            'uuid': None
                        },
                        'recordingFlag': 'Call Recording Disabled',
                        'audibleMwi': 'Default',
                        'speedDial': None,
                        'partitionUsage': 'General',
                        'associatedEndusers': {
                            'enduser': [
                                {
                                    'userId': 'user11'
                                }
                            ]
                        },
                        'missedCallLogging': 'true',
                        'recordingMediaSource': 'Gateway Preferred',
                        'ctiid': None,
                        'uuid': '{21AE71B2-4387-5D31-9360-66BAE98306DE}'
                    }
                ],
                'lineIdentifier': None
            },
            'numberOfButtons': 1,
            'phoneTemplateName': {
                '_value_1': 'Standard Dual Mode for Android',
                'uuid': '{105356B9-833A-4211-8D29-C109A00BEE00}'
            },
            'speeddials': None,
            'busyLampFields': None,
            'primaryPhoneName': {
                '_value_1': None,
                'uuid': None
            },
            'ringSettingIdleBlfAudibleAlert': 'Default',
            'ringSettingBusyBlfAudibleAlert': 'Default',
            'blfDirectedCallParks': None,
            'addOnModules': None,
            'userLocale': None,
            'networkLocale': None,
            'idleTimeout': None,
            'authenticationUrl': None,
            'directoryUrl': None,
            'idleUrl': None,
            'informationUrl': None,
            'messagesUrl': None,
            'proxyServerUrl': None,
            'servicesUrl': None,
            'services': None,
            'softkeyTemplateName': {
                '_value_1': None,
                'uuid': None
            },
            'loginUserId': None,
            'defaultProfileName': {
                '_value_1': None,
                'uuid': None
            },
            'enableExtensionMobility': 'false',
            'currentProfileName': {
                '_value_1': None,
                'uuid': None
            },
            'loginTime': None,
            'loginDuration': None,
            'currentConfig': {
                'userHoldMohAudioSourceId': None,
                'phoneTemplateName': {
                    '_value_1': 'Standard Dual Mode for Android',
                    'uuid': '{105356B9-833A-4211-8D29-C109A00BEE00}'
                },
                'mlppDomainId': None,
                'mlppIndicationStatus': 'Off',
                'preemption': 'Disabled',
                'softkeyTemplateName': {
                    '_value_1': None,
                    'uuid': None
                },
                'ignorePresentationIndicators': 'false',
                'singleButtonBarge': 'Default',
                'joinAcrossLines': 'Off',
                'callInfoPrivacyStatus': 'Default',
                'dndStatus': None,
                'dndRingSetting': 'Disable',
                'dndOption': 'Call Reject',
                'alwaysUsePrimeLine': 'Default',
                'alwaysUsePrimeLineForVoiceMessage': 'Default',
                'emccCallingSearchSpaceName': {
                    '_value_1': None,
                    'uuid': ''
                },
                'deviceName': None,
                'model': None,
                'product': None,
                'deviceProtocol': None,
                'class': None,
                'addressMode': None,
                'allowAutoConfig': None,
                'remoteSrstOption': None,
                'remoteSrstIp': None,
                'remoteSrstPort': None,
                'remoteSipSrstIp': None,
                'remoteSipSrstPort': None,
                'geolocationInfo': None,
                'remoteLocationName': None
            },
            'singleButtonBarge': 'Default',
            'joinAcrossLines': 'Off',
            'builtInBridgeStatus': 'Default',
            'callInfoPrivacyStatus': 'Default',
            'hlogStatus': 'On',
            'ownerUserName': {
                '_value_1': None,
                'uuid': None
            },
            'ignorePresentationIndicators': 'false',
            'packetCaptureMode': 'None',
            'packetCaptureDuration': 0,
            'subscribeCallingSearchSpaceName': {
                '_value_1': None,
                'uuid': None
            },
            'rerouteCallingSearchSpaceName': {
                '_value_1': None,
                'uuid': None
            },
            'allowCtiControlFlag': 'true',
            'presenceGroupName': {
                '_value_1': 'Standard Presence group',
                'uuid': '{AD243D17-98B4-4118-8FEB-5FF2E1B781AC}'
            },
            'unattendedPort': 'false',
            'requireDtmfReception': 'false',
            'rfc2833Disabled': 'false',
            'certificateOperation': 'No Pending Operation',
            'authenticationMode': None,
            'keySize': None,
            'keyOrder': None,
            'ecKeySize': None,
            'authenticationString': None,
            'certificateStatus': 'None',
            'upgradeFinishTime': None,
            'deviceMobilityMode': 'Default',
            'roamingDevicePoolName': None,
            'remoteDevice': 'false',
            'dndOption': 'Call Reject',
            'dndRingSetting': 'Disable',
            'dndStatus': 'false',
            'isActive': 'true',
            'isDualMode': 'true',
            'mobilityUserIdName': {
                '_value_1': None,
                'uuid': None
            },
            'phoneSuite': 'Default',
            'phoneServiceDisplay': 'Default',
            'isProtected': 'false',
            'mtpRequired': 'false',
            'mtpPreferedCodec': '711ulaw',
            'dialRulesName': {
                '_value_1': None,
                'uuid': None
            },
            'sshUserId': None,
            'sshPwd': None,
            'digestUser': None,
            'outboundCallRollover': 'No Rollover',
            'hotlineDevice': 'false',
            'secureInformationUrl': None,
            'secureDirectoryUrl': None,
            'secureMessageUrl': None,
            'secureServicesUrl': None,
            'secureAuthenticationUrl': None,
            'secureIdleUrl': None,
            'alwaysUsePrimeLine': 'Default',
            'alwaysUsePrimeLineForVoiceMessage': 'Default',
            'featureControlPolicy': {
                '_value_1': None,
                'uuid': None
            },
            'deviceTrustMode': 'Not Trusted',
            'earlyOfferSupportForVoiceCall': None,
            'requireThirdPartyRegistration': None,
            'blockIncomingCallsWhenRoaming': None,
            'homeNetworkId': None,
            'AllowPresentationSharingUsingBfcp': 'false',
            'confidentialAccess': {
                'confidentialAccessMode': None,
                'confidentialAccessLevel': -1
            },
            'requireOffPremiseLocation': None,
            'allowiXApplicableMedia': 'false',
            'cgpnIngressDN': {
                '_value_1': None,
                'uuid': None
            },
            'useDevicePoolCgpnIngressDN': 'true',
            'msisdn': None,
            'enableCallRoutingToRdWhenNoneIsActive': 'false',
            'wifiHotspotProfile': {
                '_value_1': None,
                'uuid': None
            },
            'wirelessLanProfileGroup': {
                '_value_1': None,
                'uuid': None
            },
            'elinGroup': {
                '_value_1': None,
                'uuid': None
            },
            'ctiid': 22,
            'uuid': '{93ABE697-403C-F042-60D3-D7694DC05792}'
        }
    },
    'sequence': None
}

1. The version of zeep (or if you are running master the commit hash/date)

zeep==2.5.0

2. The WSDL you are using

Cisco CUCM AXL

wsdl
xsd

3. An example script

See below:

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 = 'admin'
PASSWORD = 'cisco'
IP_ADDRESS = "192.168.99.99"
WSDL = 'file://path/to//AXLAPI.wsdl'
BINDING_NAME = "{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
ADDRESS = "https://{ip}:8443/axl/".format(ip=IP_ADDRESS)


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)

    kwargs = {"name": "BOTUSER011"}
    print((axl.getPhone(**kwargs)))


if __name__ == '__main__':
    main()

All 7 comments

Found my answer in the docs and source... please close...

Okay :-)

@jonathanelscpt mind SHARING the answer?

As I said to my earlier self - RTFM. If you want to be rude, don't expect a friendly answer.

As I said to my earlier self - RTFM. If you want to be rude, don't expect a friendly answer.

please? :-)

Found my answer in the docs and source... please close...

Please share your answer.

Looks like here: https://python-zeep.readthedocs.io/en/master/datastructures.html#xsd-choice

This is a feature of the library and the way it deals with multiple data items in the return data.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

majackson picture majackson  路  6Comments

ZeWaren picture ZeWaren  路  3Comments

olivierverville picture olivierverville  路  3Comments

YAmikep picture YAmikep  路  3Comments

grguthrie picture grguthrie  路  4Comments