PHP Soap Issue: Server was unable to process request. ---> Object reference not set to an instance of an object

旧巷老猫 提交于 2019-12-22 12:45:11

问题


I'm using PHP 5.2.5.5 with Moodle 1.9.

When I make a simple SOAP call without parameters, it works. However, as soon as I use a call with a parameter, it fails. If I capture the SOAP request with Fiddler, I see that it's not adding the parameter to the soap request at all.

Here's my sample code:

$WSDL = 'http://www.nanonull.com/TimeService/TimeService.asmx?WSDL';
$client = new SoapClient($WSDL);
$response = $client->getUTCTime(); // WORKS
$response = $client->getTimeZoneTime('ZULU');  // SOAP FAULT

Any suggestions?


回答1:


You need to pass the name of that parameter as well (and pass in an array):

$WSDL = 'http://www.nanonull.com/TimeService/TimeService.asmx?WSDL';
$client = new SoapClient($WSDL);
$response = $client->getUTCTime(); // WORKS

$response = $client->getTimeZoneTime(array('timezone'=>'ZULU')); //works
print_r( $response);

see: http://www.nanonull.com/TimeService/TimeService.asmx?op=getTimeZoneTime

and: http://www.nanonull.com/TimeService/TimeService.asmx

Jack



来源:https://stackoverflow.com/questions/927566/php-soap-issue-server-was-unable-to-process-request-object-reference-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!