cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
770
Views
0
Helpful
1
Replies

Error while invoking selectCmDeviceExt API

dilipreddy.guda
Level 1
Level 1

I am running into below issue while invoking "selectCmDeviceExt" API.

The idea is to fetch phone details whose model number is 688 (i.e. SX-80 devices)

code snippet :

SRV_CMSERVER='X.X.X.X' #PUB IP of SIN CUCM cluster

SRV_axl_port='8443'

SRV_user='appadmin'

SRV_passwd='XXXXXXX'


SRV_wsdl='https://'+SRV_CMSERVER+':'+SRV_axl_port+'/realtimeservice2/services/RISService70?wsdl'

SRV_location='https://'+SRV_CMSERVER+':'+SRV_axl_port+'/realtimeservice2/services/RISService70'


t = HttpAuthenticated(username='dilipreddy.guda', password='XXXXXXXX')

t.handler=urllib.request.HTTPBasicAuthHandler(t.pm)

ssl_def_context = ssl.create_default_context()

ssl_def_context.check_hostname = False

ssl_def_context.verify_mode = ssl.CERT_NONE

t1=urllib.request.HTTPSHandler(context=ssl_def_context)

t.urlopener = urllib.request.build_opener(t.handler,t1)


tns = 'http://schemas.cisco.com/ast/soap/'

imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/')

imp.filter.add(tns)


client=Client(SRV_wsdl,location=SRV_location,plugins=[ImportDoctor(imp)],transport=t)

result = client.service.selectCmDeviceExt('',{'SelectBy':'Name', 'Status':'Any', 'Class':'Phone', 'Model':'688', 'MaxReturnedDevices' : '1000'})   -- > This is where error is observed.



Error snippet :


Traceback (most recent call last):

  File "CUCM_AXL_TP_endpoints.py", line 60, in <module>

    result = client.service.selectCmDeviceExt('',{'SelectBy':'Name', 'Status':'A

ny', 'Class':'Trunk', 'Model':'688', 'MaxReturnedDevices' : '1000'}) # SX-80

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\client.py", line 521, in __call__

    return client.invoke(args, kwargs)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\client.py", line 576, in invoke

    soapenv = binding.get_message(self.method, args, kwargs)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\bindings\binding.py", line 109, in get_message

    content = self.bodycontent(method, args, kwargs)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\bindings\document.py", line 95, in bodycontent

    add_param, self.options().extraArgumentErrors)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\argparser.py", line 83, in parse_args

    return arg_parser(args, kwargs, extra_parameter_errors)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\argparser.py", line 108, in __call__

    self.__process_parameters()

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\argparser.py", line 299, in __process_parameters

    self.__process_parameter(*pdef)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\argparser.py", line 294, in __process_parameter

    self.__in_choice_context(), value)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\bindings\document.py", line 86, in add_param

    p = self.mkparam(method, pdef, value)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\bindings\document.py", line 130, in mkparam

    return Binding.mkparam(self, method, pdef, object)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\bindings\binding.py", line 225, in mkparam

    return marshaller.process(content)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\core.py", line 59, in process

    self.append(document, content)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\core.py", line 72, in append

    self.appender.append(parent, content)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\appender.py", line 88, in append

    appender.append(parent, content)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\appender.py", line 229, in append

    Appender.append(self, child, cont)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\appender.py", line 168, in append

    self.marshaller.append(parent, content)

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\core.py", line 71, in append

    if self.start(content):

  File "C:\Users\dilipreddy.guda\AppData\Local\Programs\Python\Python36\lib\site-packages\suds\mx\literal.py", line 86, in start

    raise TypeNotFound(content.tag)

suds.TypeNotFound: Type not found: 'Class'

If I use "selectCmDevice" API  with below WSDL then the API works fine. But the problem here is there is no "selectCmDeviceExt" API in this wsdl . Want to use "selectCmDeviceExt" API as this This request consolidates device records across nodes, returning only the device info for the latest registration.


SRV_wsdl='https://'+SRV_CMSERVER+':'+SRV_axl_port+'/realtimeservice/services/RisPort?wsdl'

SRV_location='https://'+SRV_CMSERVER+':'+SRV_axl_port+'/realtimeservice/services/RisPort'

result = client.service.SelectCmDevice('',{'SelectBy':'Name', 'Status':'Any', 'Class':'Phone', 'Model':'688', 'MaxReturnedDevices' : '1000'})

Would appreciate your help to resolve this issue. Let me know if any further details are required.

Python environment details :

Pyhton -- 3.6.3 version

requests==2.18.4

scp==0.10.2

six==1.11.0

suds==0.4

suds-jurko==0.6

textfsm==0.3.2

urllib3==1.22

1 Reply 1

dstaudt
Cisco Employee
Cisco Employee

Looks like I was able to get it working with this code:

# Installing a root/CA Certificate

# (Tested on Ubuntu 16.10, 17.10)

# Retrieve certificate from CUCM

#    - openssl s_client -showcerts -connect cucm-node.example.com:443 </dev/null 2>/dev/null|openssl x509 >cucm-node.example.com.crt

# Store certificate on the client

#    - Create a directory for extra CA certificates in /usr/share/ca-certificates:

#        sudo mkdir /usr/share/ca-certificates/extra

#    - Copy the CA .crt file to this directory:

#        sudo cp foo.crt /usr/share/ca-certificates/extra/foo.crt

#    - Append the certificate path (relative to /usr/share/ca-certificates) to /etc/ca-certificates.conf

#        sudo dpkg-reconfigure ca-certificates

# In case of a .pem file, it must first be converted to a .crt file:

#    openssl x509 -in foo.pem -inform PEM -out foo.crt

from suds.client import Client

# import logging

# logging.basicConfig(level=logging.INFO)

# logging.getLogger("suds.transport").setLevel(logging.DEBUG)

client = Client("file:////home/dstaudt/Documents/Serviceability/v10.5(1)/RISService70.wsdl",

    location="https://ds-ucm105.cisco.com:8443/realtimeservice2/services/RISService70",

    username="Administrator",

    password="ciscopsdt")

CmSelectionCriteria = {

    "MaxReturnedDevices": "1000",

    "DeviceClass": "Phone",

    "Model": 30016,

    "Status": "Any",

    "NodeName": "",

    "SelectBy": "Name",

    "SelectItems": {

        "item": {

            "Item": "*"

        }

    },

    "Protocol": "Any",

    "DownloadStatus": "Any"

}

result = client.service.selectCmDevice("",CmSelectionCriteria)

print(result)

Note, I found this little sample, which helps you inspect the object schema created when the WSDL is imported by suds-jurko:

import sys, getopt

from suds.client import Client

def getAvailableMethods(client):

    methods = [method for method in client.wsdl.services[0].ports[0].methods]

    return methods

def printAvailableMethods(method_names):

    print("These are all the methods available: ")

    for method_name in method_names:

        param_names = getMethodParams(method_name)

        sys.stdout.write(" * " + method_name + ": ")

        for param_name in param_names:

            sys.stdout.write(param_name + " ")

        sys.stdout.write("\n")

def callSampleMethods(method_names):

    print("Calling all methods that don't need any parameters.")

    for method_name in method_names:

        if len(getMethodParams(method_name)) == 0:

            print(" * " + method_name)

            result = getattr(client.service, method_name)()

            print(result)

def getMethodParams(method_name):

    method = client.wsdl.services[0].ports[0].methods[method_name]

    params = method.binding.input.param_defs(method)

    param_names = []

    for param in params:

        param_names.append(param[0])

    return param_names

if __name__ == "__main__":

    # Start a client and point to the WSDL URL

    client = Client("file:////home/dstaudt/Documents/Serviceability/v10.5(1)/RISService70.wsdl",

        location="https://ds-ucm105.cisco.com:8443/realtimeservice2/services/RISService70",

        username="Administrator",

        password="ciscopsdt")

    print(client)

    # Get some info from available funtionality

    availableMethods = getAvailableMethods(client)

    printAvailableMethods(availableMethods)

    # callSampleMethods(availableMethods)

Based on the work found here: suds-jurko/client.py at master · raquel-ucl/suds-jurko · GitHub