Question

I have a web service available @ http://www.xxxxx/zzzzzzzz/service.asmx and I am trying to send a SOAP request for method - some_function with both the parameters but still not able to get the connection through.

This is my code:

<?php

$param = array('cedula'=>'XXXX','contrasena'=>'YYYYYY');

$client = new SoapClient("http://www.xxxxx/zzzzzzzz/service.asmx?wsdl");
$result = $client->__soapCall('some_function', $param);

print $result;

?>

Error that I'm getting is:

Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in /home/zzzz/XXXXXXXXXX.com/uni/index.php:6 Stack trace: #0 /home/zzzz/XXXXXXXXXX.com/uni/index.php(6): SoapClient->__soapCall('some_function' , Array) #1 {main} thrown in /home/zzzz/XXXXXXXXXX.com/uni/index.php on line 6

Please suggest the corrections. Many thanks in advance :)

Was it helpful?

Solution

Thanks @dootzky & @lulco. I have solved this. Code below works perfectly fine for me:

<?php

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.xxxxxxx/zzzzzzzzzz/service.asmx?WSDL";

$login_id = 'XXXX';
$password = 'YYYYYY';

$client = new SoapClient($wsdl_path, array('trace' => 1));

try {
    echo "<pre>\n";
    $result = $client->SOME_FUNCTION(array("request" => array("cedula" => $login_id, "contrasena" => $password)))
    print_r($result);
    echo "\n";
}
catch (SoapFault $exception) {
    echo $exception;      
} 

?>

OTHER TIPS

I think you are very close to getting this code to work. I would also give credit to this answer on StackOverflow, looks very similar to what you are asking:

"Object reference not set to an instance of an object" error connecting to SOAP server from PHP

So maybe you should just shoot the method directly, like so:

$client->SOME_FUNCTION(array("request" => array('cedula'=>'XXXX','contrasena'=>'YYYYYY'));

Hope that helps! :)

I think it could be problem in wsdl for service SOME_FUNCTION.

Here is the list of services: http://www.xxxxxx/zzzzzzzzzz/service.asmx

All of them work, but SOME_FUNCTION doesn't. Go to url http://www.xxxxxx/zzzzzzzzzz/service.asmx?op=SOME_FUNCTION and try to set parameters and click Invoke. It will not work and throw exception "Object reference not set to an instance of an object.". Then try another service, it will work and return some result.

Example for OTHER_FUNCTION service works:


$param = array('estatus'=>'XXXX');

$client = new SoapClient("http://www.xxxxxx/zzzzzzzzzz/service.asmx?wsdl");
$result = $client->__soapCall('OTHER_FUNCTION', $param);

print_r($result);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top