WSDL Tutorials - Herong's Tutorial Examples - Version 2.03, by Dr. Herong Yang
Using Operation Name as the SOAP Body Element Name
This section provides a tutorial example on how to define the first level sub element name as the operation name in the WSDL document to make SOAP::Lite happy.
In order to make SOAP::Lite happy, I wrote a new WSDL document that defines a Web service operation called "Reservation". The first level sub element of the SOAP Body is also defined with the same name "Reservation".
The new WSDL document is located at http://www.herongyang.com/Service/ Reservation_WSDL_11_SOAP_11_Document.wsdl. Here is an example Perl program, Reservation_Client.pl, to test this Web service:
#- Reservation_Client.pl #- Copyright (c) 2009 by Dr. Herong Yang, herongyang.com #- All rights reserved # use SOAP::Lite +trace; #- Loading the WSDL document my $client = SOAP::Lite->service( 'file:///c:/herong/Reservation_WSDL_11_SOAP_11_Document.wsdl'); #- Making the SOAP message in a readable format $client->readable('true'); #- Building sub elements for the request $member = SOAP::Data->name('Member')->value('Herong Yang'); $item1 = SOAP::Data->name('Item')->value('Java Web Services'); $item2 = SOAP::Data->name('Item')->value('SOAP Programming'); $itemList = SOAP::Data->name('ItemList') ->value(\SOAP::Data->value($item1, $item2)); #- Calling the operation $result = $client->Reservation($member,$itemList); #- Showing the result print "Result is: $result\n";
Execution result of Reservation_Client.pl:
C:\herong\>Reservation_Client.pl SOAP::Transport::HTTP::Client::send_receive: POST http://www.herongyang.com/Serice/Reservation.php HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 761 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://www.herongyang.com/Service/Reservation" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:hy="http://www.herongyang.com/Service/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <hy:Reservation> <Member xsi:type="xsd:string">Herong Yang</Member> <ItemList> <Item xsi:type="xsd:string">Java Web Services</Item> <Item xsi:type="xsd:string">SOAP Programming</Item> </ItemList> </hy:Reservation> </soap:Body> </soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Content-Type: text/xml <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hy="http://www.herongyang.com/Service/"> <soapenv:Header/> <soapenv:Body> <hy:ReservationResponse> <Number>20080808</Number> <Status>Wait</Status> </hy:ReservationResponse> </soapenv:Body> </soapenv:Envelope>
The SOAP Body in the request generated by SOAP::Lite matches the XML schema in the WSDL document now.
Last update: 2009.
Table of Contents
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
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