Method Community

 

Object reference not an instance of an object.

Last post 03-08-2013 4:44 AM by Sivalal. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-14-2012 6:49 PM

    • viret56
    • Top 75 Contributor
    • Joined on 01-10-2012
    • Virginia
    • Posts 79

    Object reference not an instance of an object.

    I am using PHP 5 SoapClient class to define a SOAP client pointing to the MethodAPI service. I do this with

              $client = new SoapClient("https://www.methodintegration.com/MethodAPI/service.asmx?wsdl");

    My first test is attempting to retreive a table list using MethodTableList.  The PHP code I used is

              $rsXML = $client->MethodAPITableList($company, $user, $password, $returnedXML);

    The response returned ($rsXML->MethodAPITableListResult) is the error message,

              "Object reference not set to an instance of an object."

    The two lines of code are fairly straightforward and I can't see what is causing the error. Can someone tell me what caused that error?  Is it the $returnedXML string variable?

  • 03-15-2012 1:24 PM In reply to

    Re: Object reference not an instance of an object.

    Hi viret56,

    Have you set the variables company, user, and password? Also the variable returnedXML is supposed to be passed by ref into the function, has this been set properly?

    Dave

     

  • 03-15-2012 1:51 PM In reply to

    • viret56
    • Top 75 Contributor
    • Joined on 01-10-2012
    • Virginia
    • Posts 79

    Re: Object reference not an instance of an object.

     Hi Method_David,

    The company, user, and password are set.  For the variable returnedXML, I have tried '$returnedXML', '&$returnedXML', an empty string (''), and a literal string ('returnedXML'), all of which give me the same error message.

    By the way.  I am able to make a connection and retrieve data using PHP's CURL library.

  • 03-08-2013 4:44 AM In reply to

    Re: Object reference not an instance of an object.

    Answer

    Hi viret56,

    Pass the variables in an array

    $client->MethodAPITableList(array("strCompanyAccount"=>$company, "strLogin"=>$user,"strPassword"=> $password, "xmlReturned"=>$returnedXML));

    $returnedXML=''; // an empty string is enough

Page 1 of 1 (4 items)