Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

SOAP Web Service Tutorials - Herong's Tutorial Examples
SOAP Web Service Tutorials - Herong's Tutorial Examples
SOAP Web Service Tutorials - Herong's Tutorial Examples
Ebook606 pages

SOAP Web Service Tutorials - Herong's Tutorial Examples

Rating: 0 out of 5 stars

()

Read preview

About this ebook

This book is a collection of notes and sample codes written by the author while he was learning SOAP Web service. Topics include introduction of SOAP specifications; SOAP modules, features, and message structure; SOAP Message Exchange Patterns; Python, Perl, PHP, and Java support of SOAP Web services; WS-Security, Username Token and X.509 Token; Signing and Encrypting SOAP messages; Using SoapUI for Web service testing. Updated in 2024 (Version v5.13) with Python tutorials.

For latest updates and free sample chapters, visit https://www.herongyang.com/Web-Services.
LanguageEnglish
PublisherLulu.com
Release dateSep 22, 2018
ISBN9780359107667
SOAP Web Service Tutorials - Herong's Tutorial Examples

Read more from Herong Yang

Related to SOAP Web Service Tutorials - Herong's Tutorial Examples

Internet & Web For You

View More

Reviews for SOAP Web Service Tutorials - Herong's Tutorial Examples

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    SOAP Web Service Tutorials - Herong's Tutorial Examples - Herong Yang

    The Front Cover

    SOAP Web Service Tutorials

    - Herong's Tutorial Examples

    Icon
    v5.13, 2024
    Herong Yang
    Copyright © 2002-2024 Herong Yang. All rights reserved.
    ISBN: 978-0-359-10766-7

    This book is a collection of notes and sample codes written by the author while he was learning SOAP Web service. Topics include introduction of SOAP specifications; SOAP modules, features, and message structure; SOAP Message Exchange Patterns; Python, Perl, PHP, and Java support of SOAP Web services; WS-Security, Username Token and X.509 Token; Signing and Encrypting SOAP messages; Using SoapUI for Web service testing. Updated in 2024 (Version v5.13) with Python tutorials.

    Table of Contents

    About This Book

    Introduction to Web Service

    What Is a Web Service

    Web Service Related Technologies

    Introduction to SOAP (Simple Object Access Protocol)

    What Is SOAP

    SOAP Communication Example

    SOAP Message Structure

    SOAP Generic Message Structure

    SOAP Fault Message Structure

    SOAP Message Transmission and Processing

    SOAP Protocol Binding

    SOAP Distributed Processing Model

    SOAP Features and Modules

    SOAP Data Model

    SOAP Encoding

    What Is SOAP Encoding

    Multiple References and Circular References

    Node Types - simple, struct, array

    SOAP Encoding Attributes and Namespace

    Using SOAP Encoding in SOAP Messages

    SOAP RPC Presentation

    What Is SOAP RPC Presentation

    Using Web Methods to Invoke RPC

    Using SOAP Messages to Invoke RPC

    RPC Response Messages

    SOAP Properties Model

    SOAP MEP (Message Exchange Patterns)

    What Are SOAP Message Exchange Patterns

    Request-Response Message Exchange Pattern

    Response Message Exchange Pattern

    Web Method Feature

    SOAP Action Feature

    SOAP HTTP Binding

    SOAP PHP Implementations

    SOAP PHP Implementations: PEAR::Package::SOAP and NuSOAP

    PHP 7.0.2 by The PHP Group

    What Is PHP SOAP Extension

    Installing SOAP Extension on Windows

    PHP SOAP Extension Client Programs

    PHP SOAP Extension Functions for Client Programs

    Calling WSDL Operation Directly

    Call WSDL Operation with SoapClient::__soapCall()

    Dumping SOAP Request and Response

    Call WSDL Operation with SoapClient::__doRequest()

    PHP SOAP Extension Server Programs

    PHP SOAP Extension Functions for Server Programs

    HelloServer.php - First SOAP Server Application

    HelloServer12.php - SOAP 1.2 Server Application

    HelloServerWsdl.php - SOAP 1.2 Server in WSDL Mode

    HelloServerWsdl2.php - SOAP 1.1/1.2 Server in WSDL Mode

    PHP SOAP Web Service Example - getTemp

    TemperatureService.wsdl - getTemp WSDL Document

    TemperatureService.php - getTemp Server Programs

    GetTemp.php - getTemp Client Program

    GetTempDump.php - Dumping Debugging Information

    GetTempNonWsdl.php - Using non-WDSL Mode

    GetTemp12.php - SOAP 1.2 Client Example

    GetTempDoRequest12.php - SOAP 1.2 Client Example

    SOAP Perl Implementations

    SOAP Perl Implementation - SOAP::Lite

    Installing ActivePerl Latest Version on Windows

    Installing SOAP::Lite Package

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

    SOAP Communication Model

    What Is SOAP::Lite

    SOAP::Transport::TCP::Server - SOAP Server with TCP Protocol

    SoapTcpClient.pl - SOAP Client Example with TCP Protocol

    SOAP::Lite Tracing Functions

    SOAP::Transport::HTTP - SOAP Server with HTTP Protocol

    Perl Socket Test Program for HTTP and SOAP

    SocketRequestResponse.pl - Socket Level Testing Program

    Examples of HTTP 1.0 Requests and Responses

    Examples of HTTP 1.1 Requests and Responses

    SOAP 1.1 Request - Content-Length Too Small

    SOAP 1.1 Request - Content-Length Too Large

    SOAP 1.1 Request and Response of GetTemp

    SOAP 1.2 Request and Response of GetTemp

    Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

    NumberToWords Failed - Unexpected Parameter c-gensym3

    NumberToWords Failed - Invalid namespace

    NumberToWords Worked - Setting Namespace and Parameter

    Perl SOAP::Lite for SOAP 1.2 Web Services

    Message Styles Supported in SOAP::Lite

    Methods on SOAP::Lite Client Object

    Testing SOAP::Lite Client Objects

    Differences between SOAP 1.1 and SOAP 1.2

    NumberToWords_localhost.pl - Testing on Local Host

    soapversion('1.2') and envprefix('soap12') Must Used Together

    default_ns() - Setting Namespace for Body Elements

    SOAP::Data - Utility Class to Generate XML Elements

    SOAPAction - Not Needed, But No Way to Remove It

    NumberToWords_SOAP_1_2.pl - SOAP::Lite for SOAP 1.2 Web Service

    Perl SOAP::Lite for WSDL

    First WSDL Test Worked with SOAP::Lite

    Using SOAP 1.2 with SOAP::Lite in WSDL Mode

    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

    What Is SAAJ (SOAP with Attachments API for Java)

    SOAP Java Implementations: Axis and Apache WebService

    Axis Installation Requirements on Windows

    Installing Axis 1.2.1 on Windows

    Installing JAF 1.0.2

    Java Socket and HttpURLConnection for SOAP

    SocketRequestResponse.java - Socket Client Testing Program

    SocketRequestResponseServer.java - Socket Server Testing Program

    Capturing the HTTP Request from a Browser

    read(byteBuf) = -1 Not Working

    Using java.net.HttpURLConnection to Send SOAP Messages

    Using HttpURLConnection to Call SOAP 1.1

    Capturing HTTP Request Generated by the HttpURLConnection Class

    Calling NumberToWords SOAP 1.1 Web Service

    Using HttpURLConnection to Call SOAP 1.2

    Calling NumberToWords SOAP 1.2 Web Service

    SAAJ - SOAP with Attachments API for Java

    SAAJ API Classes and Interfaces Overview

    SAAJ API and Default Implementation in JDK

    Check SAAJ API Version in JDK

    SAAJ API Reference Implementation

    First SOAPConnection Test Program

    Creating SOAPConnection and SOAPMessage Objects

    SAAJ SOAPMessage Structure and Classes/Interfaces

    Populating the SOAP Body with Request XML Elements

    Don't Use xml* as namespace Prefix

    addHeader() - Setting SOAPAction Header Line

    Calling NumberToWords SOAP 1.1 with SAAJ

    SOAPConstants.SOAP_1_2_PROTOCOL

    Calling NumberToWords SOAP 1.2 with SAAJ

    SoapUI - SOAP Web Service Testing Tool

    What Is SoapUI

    Downloading and Installing SoapUI

    Validating and Inspecting WSDL Documents

    Using Interface Viewer on Bindings

    Generating SOAP Test Request

    Submitting SOAP Test Requests to Server

    WS-Security - SOAP Message Security Extension

    What Is WS-Security (WSS)

    Using XML Signature and Encryption with WSS

    SOAP Header Element Security

    What Is WS-Security Username Token Profile

    SoapUI Configuration for Username Token

    Generating Username Token with SoapUI

    Validating wsse:Password Digest String

    Password Digest Validation Program

    WS-Security X.509 Certificate Token

    What Is WS-Security X.509 Certificate Token Profile

    What Is XML Signature Syntax and Processing

    Generating a Self-Signed Certificate with keytool

    SoapUI Configuration for Messaging Signing

    Generating Digital Signature with SoapUI

    Validating ds:Signature with X.509 Certificate

    Digital Signature Options Supported in SoapUI

    What Is XML Encryption Syntax and Processing

    SoapUI Configuration for Messaging Encryption

    not an RSA key - Encryption Failed in SoapUI

    Encryption using RSA Public Key with SoapUI

    2-Step Message Encryption - Symmetric and RSA

    Decrypting Encrypted SOAP Message

    Message Encryption Options Supported in SoapUI

    Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

    GetSpeech Failed - Incorrect SOAPAction Header Line

    GetSpeech Failed - Incorrect Parameter Name c-gensym

    Using Socket Program to Request Parameter Name

    GetSpeech Worked - Using SOAP::Data Class and on_action() Function

    GetSpeech_SOAP_1_1.pl - SOAP::Lite for SOAP 1.1 Web Service

    Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

    Installing SOAP::Lite 0.710 to Support SOAP 1.2

    GetSpeech Request Differences between SOAP 1.1 and 1.2

    Unsupported Media Type: application/soap

    DEFAULT_HTTP_CONTENT_TYPE='application/soap+xml'

    content_type() method in the HTTP::Headers Class

    Perl SOAP::Lite 0.710 for WSDL

    First WSDL Test Failed with SOAP::Lite

    Downloading and Editing WSDL Document

    Testing service() Function Locally

    soapversion('1.2') Sets Correct Envelope namespace

    Error: Object reference not set to an instance of an object

    Web Services and SOAP Terminology

    Archived Tutorials

    Archived SOAP::Lite 0.55 in ActivePerl 5.8.7

    Archived: SOAP 1.1 Request - Content-Length Too Small

    Archived: SOAP 1.1 Request - Content-Length Too Large

    Archived: SOAP 1.1 Request and Response of GetSpeech

    Archived: SOAP 1.2 Request and Response of GetSpeech

    Archived: Calling GetSpeech SOAP 1.1 with SAAJ

    Archived: Calling GetSpeech SOAP 1.2 with SAAJ

    References

    Keywords: SOAP, UDDI, WSDL, Web service

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    ∟ About This Book

    This section provides some detailed information about this book - SOAP Web Service Tutorials - Herong's Tutorial Examples.

    Title: SOAP Web Service Tutorials - Herong's Tutorial Examples

    Author: Herong Yang - Contact by email via herong_yang@yahoo.com.

    Category: COMPUTERS / Web / Web Services & API

    Version/Edition: v5.13, 2024

    Number of pages in PDF format: 374

    Description: This book is a collection of notes and sample codes written by the author while he was learning SOAP Web service. Topics include introduction of SOAP specifications; SOAP modules, features, and message structure; SOAP Message Exchange Patterns; Python, Perl, PHP, and Java support of SOAP Web services; WS-Security, Username Token and X.509 Token; Signing and Encrypting SOAP messages; Using SoapUI for Web service testing. Updated in 2024 (Version v5.13) with Python tutorials.

    Keywords: SOAP, Web Service, WSDL, Java, Perl, PHP, Python, WS-Security

    Copyright:

    This book is under Copyright Copyright © 2002-2024 Herong Yang. All rights reserved.

    Material in this book may not be published, broadcasted, rewritten or redistributed in any form.

    Code examples are provided as-is, with no warranty of any kind.

    Revision history:

    Version v5.13, 2024. Added Python tutorials

    Version 5.00, 2014. Added WS security tutorials

    Version 4.00, 2009. Added SOAP 1.2 tutorials

    Version 3.00, 2007. Added PHP tutorials

    Version 2.00, 2005. Added Java tutorials

    Version 1.00, 2002. First edition

    Web version: https://www.herongyang.com/Web-Services - Provides free sample chapters, latest updates and readers' comments. The Web version of this book has been viewed a total of:

    1,794,296 times as of December 2023.

    1,806,290 times as of December 2022.

    1,727,805 times as of December 2021.

    1,616,128 times as of December 2020.

    1,505,315 times as of December 2019.

    1,383,916 times as of December 2018.

    1,284,009 times as of December 2017.

    1,156,628 times as of December 2016.

    1,006,080 times as of December 2015.

    822,411 times as of December 2014.

    641,658 times as of December 2013.

    516,742 times as of December 2012.

    374,134 times as of December 2011.

    247,146 times as of December 2010.

    142,958 times as of December 2009.

    109,856 times as of July 2008.

    PDF/EPUB version: https://www.herongyang.com/Web-Services/PDF-Full-Version.html - Provides information on how to obtain the full version of this book in PDF, EPUB, or other format.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    ∟ Introduction to Web Service

    This chapter provides a quick introduction on Web services and related technologies: SOAP, UDDI, WSDL, HTTP, and XML.

    What Is a Web Service

    Web Service Related Technologies

    Takeaways:

    A Web Service is an application programming service that can be accessed remotely via standard Internet protocols using XML as the data format.

    There are several technologies related to Web Service: SOAP, UDDI, WSDL, HTTP, and XML.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    Introduction to Web Service

    ∟ What Is a Web Service

    This section describes what is a Web service.

    What Is Web Service? A Web Service is an application programming service that can be accessed remotely via standard Internet protocols using XML as the data format.

    Key elements in this definition:

    A Web service is a programming service, not an end user service

    A Web service is designed to be used remotely.

    A Web service is accessible via standard Internet protocols, ex. HTTP.

    A Web service communicates data in XML format.

    Benefits of using Web services:

    Easier to integrate applications together.

    Services re-usable.

    Making application flexible to meeting constantly changing business needs.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    Introduction to Web Service

    ∟ Web Service Related Technologies

    This section describes a list of technologies that related to Web services.

    There are several technologies that are related to Web services:

    UDDI (Universal Description, Discovery and Integration) - A server acting like a Web service directory. Web services can be registered and discovered on a UDDI server.

    WSDL (Web Services Description Language) - An XML based language to describe a Web service.

    SOAP (Simple Object Access Protocol) - An XML based protocol used to define requests and responses for a Web service.

    HTTP (Hyper-Text Transport Protocol) - An Internet communication protocol used by the World Wild Web system. HTTP are used to deliver Web service requests and responses.

    XML (eXtensible Markup Language) - A markup language used to organize information in clear text format.

    The following diagram is an illustration of how these technologies are used to deliver a Web service from a provider to a consumer:

                          Query for a service                           

    Web service <-----------------------------------------> UDDI server

    consumer            Return provider location          | 

                                                            |

                                                            |

                    Query for the service description      v       

    Web service <-----------------------------------------> WSDL document

    consumer            Return service description          server   

                                                            |

                                                            |

                    Send service request (SOAP + HTTP)      v

    Web service <-----------------------------------------> Web Service

    consumer      Return service response (SOAP + HTTP)    provider

    As you can see from this diagram, UDDI and WSDL are really optional. If you know the location and the description of a Web service, you don't need to query the UDDI server and fetch the WSDL document. All you need to do is to build a request in SOAP format, and sent it via HTTP to the provider.

    Since HTTP is a very old protocol, I will not discuss it in this book.

    Most of the notes in this book will be on SOAP, because it is the key technology of Web services.

    Of course, some of the notes will be on UDDI and WSDL.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    ∟ Introduction to SOAP (Simple Object Access Protocol)

    This chapter provides a quick introduction to SOAP (Simple Object Access Protocol).

    What Is SOAP

    SOAP Communication Example

    Takeaways:

    SOAP is an XML based protocol intended for exchanging structured information in a distributed application environment.

    A SOAP message can be delivered with HTTP or SMTP protocol.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    Introduction to SOAP (Simple Object Access Protocol)

    ∟ What Is SOAP

    This section provides a quick summary of SOAP protocol.

    What Is SOAP (Simple Object Access Protocol)? SOAP is an XML based protocol intended for exchanging structured information in a distributed application environment. Visit https://www.w3.org/TR/soap/ for more information.

    There are 2 versions of SOAP specifications as of today:

    Version    Release Date    Namespace

     

    SOAP 1.2  April 27, 2007  http://www.w3.org/2003/05/soap-envelope

    SOAP 1.1  May 8, 2000      http://schemas.xmlsoap.org/soap/envelope/

    SOAP 1.2 specification is divided into two parts.

    SOAP part 1 defines the SOAP messaging framework, which contains the following key concepts:

    SOAP Message Construct - How a SOAP message should be constructed.

    SOAP Protocol Binding Framework - How a SOAP message should be bound a communication protocol to carry it from the sender to the receiver.

    SOAP Processing Model - How a SOAP message should be processed by SOAP receivers.

    SOAP Extensibility Model - How SOAP can be extended to add SOAP features and SOAP modules.

    SOAP part 2 defines a set of adjuncts that can be used to extend the SOAP messaging framework:

    SOAP Data Model - How data structures and values should be represented as a graph of nodes.

    SOAP Encoding - How data presented in SOAP Data Model should be encoded as XML data.

    SOAP RPC Presentation - How Remote Procedure Call (RPC) should be modeled with SOAP.

    SOAP Convention for Describing Features and Bindings - How SOAP Features and Bindings should be described.

    SOAP Supplied Features - Commonly used SOAP extensions.

    SOAP HTTP Binding - How a SOAP message is bound to HTTP.

    SOAP is actually a communication protocol that defines how a message should be constructed, transmitted from one node to another, and processed by each node as shown in the following diagram:

    SOAP node         

    |

    | Construct an initial SOAP message

    | Bind the initial message for transmission

    | Transmit the initial message

    v

    ----------> SOAP node

                  | 

                  | Receive the initial message

                  | Process some part of the initial message

                  | Reconstruct an intermediate SOAP message

                  | Bind the intermediate message for transmission

                  | Transmit the intermediate message

                  v

                  ----------> SOAP node

                              |

                              | ...

                              v

                              ----------> SOAP node

                                            |

                                            | Receive the final message

                                            | Process the final message

                                            v

                                            Done

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    Introduction to SOAP (Simple Object Access Protocol)

    ∟ SOAP Communication Example

    This section describes an simple example of SOAP communication.

    Before going into details of the SOAP specification, let's try a very simple SOAP example. There are 3 basic steps involved in a SOAP communication:

    1. Creating a SOAP message. This is easy. Just use any text editor to enter the following SOAP message, hello.msg:

    http://www.w3.org/2003/05/soap-envelope>

      http://herong.com/header>

      Herong

     

      http://herong.com/body>

      Hello there!

     

    2. Transmitting the message from a SOAP node, my machine, to another SOAP node, your machine. A simple way to do this is for me to send hello.msg to you as an email, so you will get something like this:

    From: herong@my.com

    To: you@your.com

    Subject: Greeting

     

    http://www.w3.org/2003/05/soap-envelope>

      http://herong.com/header>

      Herong

     

      http://herong.com/body>

      Hello there!

     

    3. Processing the message. Once you got my SOAP message, you should be able to read it, and do whatever you want to do with it.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    ∟ SOAP Message Structure

    This chapter provides descriptions of SOAP message structures and sample messages.

    SOAP Generic Message Structure

    SOAP Fault Message Structure

    Takeaways:

    A SOAP message is an XML document with an Envelope root element, and two child elements: Header and Body.

    A SOAP fault message is a SOAP message designed to deliver error messages.

    SOAP Web Service Tutorials - Herong's Tutorial Examples

    SOAP Message Structure

    ∟ SOAP Generic Message Structure

    This section provides a description of the SOAP generic message structure and a sample

    Enjoying the preview?
    Page 1 of 1