简体   繁体   中英

“Object reference not set to an instance of an object” error calling SOAP service from PHP

I'm attempting to access this web service via SOAP from PHP using this code:

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.neugroup.com/workarea/servercontrolws.asmx?WSDL";

$username = 'username';
$password = 'password';

$client = new SoapClient($wsdl_path, array(
  "trace"      => 1,
  "exceptions" => 0)
);
try {
  $result = $client->LoadListSummary(array(
    'LangID' => 1033,
    'FolderPath' => 'path/',
    'MaxResults' => 500,
    'OrderKey' => 'Title',
    'Direction' => 'Ascending',
    'Preview' => 0,
    'Recursive' => 0,
    'RetrieveSummary' => 0,
    'Random' => 0,
    'GetHtml' => 0,
    'ContentType' => 'AllTypes',
    )
  );
}
catch (SoapFault $exception) {
  echo $exception;
}

but I get an "Object reference not set to an instance of an object" error. I'm stepping through this is a debugger, and I can see that $client is an object. Is there something else I'm doing wrong that would cause this error? Also, am I structuring my SOAP call correctly?

Thanks.

It doesn't look like you are doing anything wrong, the error is in the service so one of two things can be the case:

  1. One of your parameters is wrong and makes the service resolve to a null object (path could be a candidate) and the server doesn't validate this and try to so operations on the object
  2. There is a general malfunction in the service you are calling

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM