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 Web Service

 Introduction to SOAP (Simple Object Access Protocol)

 SOAP Message Structure

 SOAP Message Transmission and Processing

 SOAP Data Model

 SOAP Encoding

 SOAP RPC Presentation

 SOAP Properties Model

 SOAP MEP (Message Exchange Patterns)

 SOAP HTTP Binding

 SOAP PHP Implementations

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

 PHP SOAP Web Service Example - getTemp

 SOAP Perl Implementations

 Perl SOAP::Lite - SOAP Server-Client Communication Module

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

 Perl SOAP::Lite for SOAP 1.2 Web Services

 Perl SOAP::Lite for WSDL

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

 Dump SOAP Request and Response Messages

 WSDL 2.0 Not Supported by Zeep Library

 SOAP Java Implementations

 Java Socket and HttpURLConnection for SOAP

 SAAJ - SOAP with Attachments API for Java

 SoapUI - SOAP Web Service Testing Tool

 WS-Security - SOAP Message Security Extension

 WS-Security X.509 Certificate Token

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

 Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Perl SOAP::Lite 0.710 for WSDL

 Web Services and SOAP Terminology

 Archived Tutorials

 References

 Full Version in PDF/EPUB