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

This section provides a tutorial example to try to use a SOAP 1.2 Web service with a service() call to the WSDL document. The test failed a System.NullReferenceException.

Base previous tests on my local system, I wrote this SOAP::Lite WSDL client program to try to use a SOAP 1.2 Web service:

#- Copyright (c) All Rights Reserved.
#- All rights reserved
   use SOAP::Lite +trace;

   my $wsdl = '';
   my ($phrase) = @ARGV;

#- Creating the SOAP client object
   my $client = SOAP::Lite->new()
      ->soapversion('1.2') # set to SOAP 1.2
      ->service($wsdl) # set the SOAPAction
      ->readable(true); # make the XML readable
#- Overriding the constant
      = 'application/soap+xml';

#- Calling the Web service
   my $som = $client->GetSpeech($phrase);
   my $output = $som->result;
   print $output . "\n";

But the test result is not good:

C:\herong> "To be, or not to be"

Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 831
Content-Type: application/soap+xml; charset=utf-8
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
      <Request xsi:type="s:string">To be, or not to be</Request>
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Connection: close
Date: ... 2009
Server: Microsoft-IIS/6.0
Content-Length: 690
Content-Type: application/soap+xml; charset=utf-8
Client-Response-Num: 1
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap=""
        <soap:Text xml:lang="en">
            Server was unable to process request. ---> 
            Object reference not set to an instance of an object.
            at WSShakespeare.Shakespeare.GetSpeech(String Request)
            --- End of inner exception stack trace ---
      <soap:Detail />

What's wrong here? My guess is that the parameter "Request" is under the default namespace, not is synch with the method "GetSpeech".

I cannot to fix this. May be you can.

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

 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

 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

 Outdated Tutorials


 Full Version in PDF/EPUB