Search code examples
pythonweb-serviceswsdlzeep

Python zeep overview of the services available


I have been working with python zeep to inspect the WSDL document and generates the corresponding code to use the services and types in the wsdl document.

The code below is a short example. It partially works. The problem is: These parameters is not exactly what the web service is waiting for

client = Client(wsdl='veda/wsdl/vedascore-apply-v2-0-6.wsdl')
client.service.submitEnquiry('Zeep', 'is cool')

In order to find out what I was supposed to send and to get an overview of the services available on the endpoint, I performed the following command in my terminal:

python -mzeep 'veda/wsdl/vedascore-apply-v2-0-6.wsdl'

The result of the command above is a big text file which I will attached here. Now that I have an overview of the services I guess I was supposed to create a proper call signature. I also went through the official documentation and I manage to perform the follow code:

    client = Client(wsdl='veda/wsdl/vedascore-apply-v2-0-6.wsdl')
    request_type = client.get_type('ns0:requestType')
    client.service.submitEnquiry(request_type)

The code above is not even close to the final solution. In order to build a proper call I have to understand the overview of the services available which I am struggling to do. The image below is just part of the description. If you can please give me any ideas I am more than happy to listen to you.

overview of the services

Warm Regards.

Ronildo Braga Junior


Solution

  • Just in case if you are facing the same problem, please see below how you was supposed to craft this call

        enquiry_header = {
            'client-reference': 'my-ref-101',
            'operator-id': 101,
            'operator-name': 'Adam Hills',
            'permission-type-code': 'XY',
            'product-data-level-code': 'N',
            'requested-scores': {'scorecard-id': ['VSA_2.0_XY_NR']}
        }
    
        enquiry_data = {
            'individual': {
                'current-name': {
                    'title': 'Mr',
                    'family-name': 'Hunt',
                    'first-given-name': 'Matthew',
                    'other-given-name': 'Eales'
                },
                'addresses': {
                    'address': [{
                        'type': 'C',
                        'unit-number': 12,
                        'street-number': 4,
                        'street-name': 'Huntsman',
                        'street-type': 'CIR',
                        'suburb': 'Pyrmont',
                        'state': tf.stateType('NSW'),
                        'postcode': 2011
                    }]
                },
                'drivers-license': {'number': '758811G'},
                'gender-code': 'M',
                'date-of-birth': '1970-01-26',
                'employment': {
                    'employer': [employerType(name='DATA FISH PTD LTD', type='C')]
                }
            },
            'enquiry': {
                'account-type-code': 'PR',
                'enquiry-amount': tf.MoneyType(5000, 'AUD'),
                'is-credit-review': False,
                'relationship-code': 1
            }
        }
    
        print(client.service.submitEnquiry(enquiry_header, enquiry_data))