Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SOAP server not returning value at all

Tags:

php

soap

wsdl

Here's this pressing problem that haven't worked out after working on it for days.

http://www.tabernus.com/ws/soap/server.php?WSDL should give you the WSDL file.

Inside the server.php, I wanted to return an incremented serial Number when "GetAuditInformation" method is called.

So I wrote this simple function at top:

 <?php 
 function GetAuditInformation($serialNumber) {
 $serialNumber=$serialNumber +1;
 return $serialNumber;        
 }

 ini_set("soap.wsdl_cache_enabled", "0");
 $server = new SoapServer('wsMRMAudit.wsdl');
 $server->addFunction("GetAuditInformation"); 
 $server->handle();

?>

I tested using plumvoice SOAPtester and it was able to get methods through WSDL.

http://www.plumvoice.com/soaptester/

But enter a serial number say....1000 and it should return 1001 but it returns NULL. Why is that?

like image 533
netrox Avatar asked May 20 '26 15:05

netrox


1 Answers

The parameter that gets passed into your function is not a number, it's an object. Your function definition should be this:

function GetAuditInformation($x)
{
    return array('GetAuditInformationResult' => $x->SerialNumber + 1);
}

For the complete example, let me post my test script as well, which works btw:

$s = new SoapClient('http://www.tabernus.com/ws/soap/server.php?WSDL', array('trace'=>true));

var_dump($s->GetAuditInformation(array('SerialNumber' => 1000)));

$req = $s->__getLastRequest();

function GetAuditInformation($x)
{
return array('GetAuditInformationResult' => $x->SerialNumber + 1);
}

$server = new SoapServer('http://www.tabernus.com/ws/soap/server.php?WSDL', array(
    'actor' => 'http://www.tabernus.com/ws/soap/',
    'soap_version' => SOAP_1_2
));
$server->addFunction('GetAuditInformation');

$server->handle($req);
like image 140
Ja͢ck Avatar answered May 23 '26 06:05

Ja͢ck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!