NumberToWords Worked - Setting Namespace and Parameter

This section provides a tutorial example on how to use the SOAP::Data class to build the request parameter element with correct namespace and correct element name.

To control the namespace of the SOAP body message, we need to:

Here is revised test program as NumberToWords_Namespace.pl:

#- NumberToWords_Namespace.pl
#- Copyright (c) 2005 HerongYang.com. All Rights Reserved.
#
   use SOAP::Lite +trace;
   my $client = SOAP::Lite->new();
   $client->proxy(
      'http://www.dataaccess.com/webservicesserver/NumberConversion.wso');
   $client->default_ns('http://www.dataaccess.com/webservicesserver/');

#- Building the parameter element with name and namespace
   my $parameter = SOAP::Data
        ->name("ubiNum")
        ->value(101);
   $parameter->uri('http://www.dataaccess.com/webservicesserver/');

#- Calling the server
   my $som = $client->NumberToWords($parameter);
   my $output = $som->result;
   print $output . "\n";

When executing NumberToWords_Parameter_Name.pl, I got this:

herong> NumberToWords_Namespace.pl

...
SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x30a1528)
SOAP::Transport::HTTP::Client::send_receive: POST 
   http://www.dataaccess.com/webservicesserver/NumberConversion.wso 
   HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 567
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.dataaccess.com/webservicesserver/#NumberToWords"

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
 soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soap:Body>
  <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
   <namesp1:ubiNum
    xmlns:namesp1="http://www.dataaccess.com/webservicesserver/"
    xsi:type="xsd:int">101</namesp1:ubiNum>
  </NumberToWords>
 </soap:Body>
</soap:Envelope>

SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x2e2d928)
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Server: Microsoft-IIS/8.0
Content-Length: 352
Content-Type: text/xml; charset=utf-8
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Origin: http://www.dataaccess.com
Client-Response-Num: 1
Strict-Transport-Security: max-age=31536000
Web-Service: DataFlex 18.1

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
 <m:NumberToWordsResponse
  xmlns:m="http://www.dataaccess.com/webservicesserver/">
   <m:NumberToWordsResult>one hundred and one </m:NumberToWordsResult>
 </m:NumberToWordsResponse>
  </soap:Body>
</soap:Envelope>
...

Bingo! I got my first SOAP::Lite program working with NumberToWords Web service provided by dataaccess.com.

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

 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

 Perl SOAP::Lite for WSDL

 Python SOAP Client: Zeep

 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