Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

soap object reference error

by ctaustin (Sexton)
on Nov 28, 2004 at 06:35 UTC ( #410779=perlquestion: print w/replies, xml ) Need Help??
ctaustin has asked for the wisdom of the Perl Monks concerning the following question:

I have the following code:

#!/usr/bin/perl + #use strict; use SOAP::Lite +debug; + + my $luser="my_user"; my $pass="my_pass"; + my $mls_schema="<SchemaName>NWMLSStandardXML</SchemaName>"; my $mls_status="A"; my $mls_county="lewis"; my $mls_start="2004-11-26T00:00:00"; my $mls_stop="2004-11-27T10:30:00"; + my $query="<Message><Head><UserId>$luser</UserID> <Password>$pass</Password> $mls_schema <Status>$mls_status</Status> <County>$mls_county</County> <BeginDate>$mls_start</BeginData> <EndData>$mls_stop</EndDate> </Head></Message>"; + print "Current Query: $query\n"; + my ($uri,$server,$endpoint,$soapaction,$method,$method_urn); + $uri=""; $server=''; $endpoint="$server/evernetqueryservice/evernetquery.asmx"; $method='RetrieveListingData'; + my $soap=SOAP::Lite->new(uri =>$uri, proxy => $endpoint) ->on_action(s +ub { sprintf '"%s/%s"', shift,shift }) ; + my $response=$soap->call(SOAP::Data->name($method) ->attr({xmlns=>$uri}) => SOAP::Data->name(v_strXMLQuery=>$query)); if ($response->fault){ printf "A fault (%s) occurred: %s\n", $response->faultcode,$response->faultstring. join ("\n\t",@_). +"\n"; } else {print "$response->result\n";} + exit;

When I run it I get the following error response:
Object reference not set to an instance of an object

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http: +//" xmlns:xsi=" +01/XMLSchema-instance" xmlns:xsd="">< +soap:Body><RetrieveListingDataResponse xmlns=" +erNetServices"><RetrieveListingDataResult>&lt;Listings&gt;&lt;Respons +eMessages&gt;&lt;Message&gt;&lt;Error&gt;System.NullReferenceExceptio +n: Object reference not set to an instance of an object. at System.Xml.XmlTextReader..ctor(String xmlFragment, XmlNodeType f +ragType, XmlParserContext context) at EverNetLib.EverNetUtility.QueryParseOperations.CheckWellFormedNe +ss(String v_strUserName, String v_strXmlQuery, XmlValidatingReader xv +rReader) at EverNetLib.EverNetUtility.QueryParseOperations.ValidateQuery(Str +ing v_strXmlQuery, MessageCollections&amp; r_mcMessages, Boolean blnB +uildQueryParamCollection) at EverNetQueryService.EverNetQuery.ValidAndRemotingEnabled(String +v_strXmlQuery, String v_strMethodName) at EverNetQueryService.EverNetQuery.RetrieveListingData(String v_st +rXmlQuery)&lt;/Error&gt;&lt;/Message&gt;&lt;/ResponseMessages&gt;&lt; +/Listings&gt;</RetrieveListingDataResult></RetrieveListingDataRespons +e></soap:Body></soap:Envelope>

Being new to both SOAP and object oriented programming I am not sure where this error is coming from. I am guessing it is something relatively easy. I would greatly appreciate being pointed in the right direction.

Thanks. Tony

Replies are listed 'Best First'.
Re: soap object reference error
by converter (Priest) on Nov 28, 2004 at 20:18 UTC

    A google search on "Object reference not set to an instance of an object" yields "about 39,400" hits. Judging by the first page of results, this error is common to .NET applications. Is a .NET application running server-side?

      In fact it is a .NET framework. I have already run into trouble with this with regards to the headers. Thus the
      on_action(sub { sprintf '"%s/%s"', shift,shift });
      portion. The people running the service seem to be pretty new to this whole process as well and haven't been as helpful as I would have liked.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://410779]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-01-22 15:12 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (187 votes). Check out past polls.