Invoking WSDL Services with Zeep Library

This section provides a tutorial example on how to create a Zeep client object with a WSDL URL, access a given service, and invoke a given operation.

How to Invoke WSDL Service with Zeep Library? There are 4 main steps to invoke a WSDL service and call its operation:

1. Create a zeep.client.Client object with the URL of a given WSDL document:

from zeep import Client
wsdl = "https://www.herongyang.com/Service/Hello_WSDL_11_SOAP.wsdl"
client = Client(wsdl)

2. Create a zeep.proxy.ServiceProxy object by calling the client.bind(service, port) method with a given combination of service name and port name:

service = client.bind('helloService', 'helloPort')

3. Create a zeep.proxy.OperationProxy object by accessing the service[operation] list member with a given operation name:

operation = service['Hello']

4. Invoke the operation(arguments) with required arguments:

result = operation("Hello from client.")

Here is Python script example that performs these steps with a given WSDL 1.1 document:

#- WSDL_Service_Proxy.py
#- Copyright (c) 2019 HerongYang.com. All Rights Reserved.
#
from zeep import Client
wsdl = "https://www.herongyang.com/Service/Hello_WSDL_11_SOAP.wsdl"

client = Client(wsdl)
print(type(client))

service = client.bind('helloService', 'helloPort')
print(type(service))

operation = service['Hello']
print(type(operation))

result = operation("Hello from client.")
print(result);

Run the test script:

herong$ python3 WSDL_Service_Proxy.py

<class 'zeep.client.Client'>
<class 'zeep.proxy.ServiceProxy'>
<class 'zeep.proxy.OperationProxy'>

      Hello from server - herongyang.com.

The test worked well. I got the result returned from the WSDL service provider.

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

 WSDL 2.0 Document Examples with SOAP Binding

 Using WSDL Document in Java Apache Axis2/Java for WSDL

 Apache Woden for WSDL Documents in Java

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

 Apache Axis2/Java for WSDL 1.1

 Using WSDL2Java to Generate Web Service Stub Classes

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

Python SOAP Client: Zeep

 What Is Zeep Python Library

 Installing Python Engine on macOS

 Installing Zeep Library

 Parsing WSDL Documents with Zeep Library

Invoking WSDL Services with Zeep Library

 Invoking WSDL Default Service

 WSDL 2.0 Not Supported by Zeep Library

 WSDL Related Terminologies

 Archived Tutorials

 References

 Full Version in PDF/EPUB