Calling XML Document Based Web Service

This section provides a tutorial example on how to call an XML document based Web service defined a WSDL 1.1 document with SOAP 1.1 binding.

After learning SOAP::Data and related classes, I hope I am ready to use SOAP::Lite to call my XML document based Web service defined in the WSDL document at Registration_WSDL_11_SOAP_11_Document.wsdl Here is an example Perl program,

#- Copyright (c) 2009 by Dr. Herong Yang,
#- All rights reserved
   use SOAP::Lite +trace;

#- Loading the WSDL document
   my $client = SOAP::Lite->service(

#- Making the SOAP message in a readable format

#- Building the XML document
   $guest1 = SOAP::Data->new(name=>'Guest', value=>'Herong Yang');
   $guest2 = SOAP::Data->name('Guest')->value('Joe Smith');

   $list = SOAP::Data->new();
   $list->value($guest1, $guest2);

   $request = SOAP::Data->new();
   $request->attr({'event'=>'OpenGame', 'date'=>'2008-08-08'});

#- Calling the operation
   $result = $client->Registration($request);

#- Showing the result
   print "Result is: $result\n";

Execution result of

   POST HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 805
Content-Type: text/xml; charset=utf-8
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
      <RegistrationRequest date="2008-08-08" event="OpenGame">
        <Guest xsi:type="xsd:string">Herong Yang</Guest>
        <Guest xsi:type="xsd:string">Joe Smith</Guest>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK

Do you see any wrong with the SOAP request message generated by SOAP::Lite? I do:

Conclusion, SOAP::Lite automatically generates the first level sub element of the SOAP Body element using the Web service method name, which is the operation name defined in the WSDL document.

In other word, the element name of the input message part must be the same as the name of the operation if you are defining a XML document based Web service and want to use SOAP::Lite to call it.

Last update: 2009.

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

 WSDL 20 Programming APIs and Testing Tools

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 soapUI 3.0.1 - Web Service Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension in PHP 5.3.1

Using WSDL in Perl with SOAP::Lite 0.710

 Introduction of Perl SOAP::Lite 0.710 for WSDL

 Methods on SOAP::Lite 0.710 Client Object

 Calling PRC Methods Defined in WSDL 1.1 Documents

 service() Method Returns New Objects

 SOAP::Data - XML Elements as Data Objects

 SOAP::Serializer - Converting Data Objects to XML

 Creating a Data Object for a Single XML Element

 Creating a Data Object for Nested XML Elements

 SOAP::Deserializer - Converting XML to Data Objects

Calling XML Document Based Web Service

 Using Operation Name as the SOAP Body Element Name

 Using WSDL Document in Java with Axis2 1.4.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

 WSDL Related Terminologies


 PDF Printing Version