02-04-2021 01:05 PM
Hello,
I am trying to run the following python program to obtain product information from CUCM.
The python program errors out with the following message -
Zeep error: getProductInformationList: Unknown fault occured
However while using postman I can retrieve data.
Python code below -
from lxml import etree import requests from requests import Session from requests.auth import HTTPBasicAuth from zeep import Client, Settings, Plugin from zeep.transports import Transport from zeep.exceptions import Fault import os import sys from dotenv import load_dotenv load_dotenv() DEBUG = os.getenv( 'DEBUG' ) == 'True' WSDL_FILE = 'file://C:/Users/serviceability-python-zeep-samples/schema/ControlCenterServices.wsdl' class MyLoggingPlugin( Plugin ): def egress( self, envelope, http_headers, operation, binding_options ): if not DEBUG: return xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode') print( f'\nRequest\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' ) def ingress( self, envelope, http_headers, operation ): if not DEBUG: return xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode') print( f'\nResponse\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' ) session = Session() session.verify = False requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning) username = 'admin' password = 'password' host = '1.1.1.1' session.auth = HTTPBasicAuth( os.getenv( username ), os.getenv( password ) ) transport = Transport( session = session, timeout = 10 ) settings = Settings( strict = False, xml_huge_tree = True ) plugin = [ MyLoggingPlugin() ] if DEBUG else [ ] client = Client( WSDL_FILE, settings = settings, transport = transport, plugins = plugin ) service = client.create_service( '{http://schemas.cisco.com/ast/soap}ControlCenterServicesBinding', f'https://{host}:8443/controlcenterservice2/services/ControlCenterServices' ) try: resp = service.getProductInformationList(ServiceInfo='') except Fault as err: print( f'Zeep error: getProductInformationList: {err}' ) sys.exit( 1 ) print( "\ngetProductInformationList response:\n" )
Solved! Go to Solution.