我如何从wsdl调用方法

时间:2012-03-05 06:25:19

标签: php soap wsdl

我试图从wsdl调用一个方法并收到错误。我是肥皂新手,尽我所能。我知道休息更好,但我真的想学习肥皂。这就是我到目前为止所做的:

ini_set('soap.wsdl_cache_enable', '0');
$client = new SoapClient('http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl');
$data = $client->__soapCall('GetQuote', array('GetQuote' => 'aapl'));
print $data;

我得到的错误是

Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in /Volumes/www/public/soap/s.php:5 Stack trace: #0 /Volumes/www/public/soap/s.php(5): SoapClient->__soapCall('GetQuote', Array) #1 {main} thrown in /Volumes/www/public/soap/s.php on line 5

感谢

1 个答案:

答案 0 :(得分:0)

您可以在GetQuote

中查看http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl请求的所有必需参数

您应该传递StockSymbolLicenseKey。请求示例:

ini_set('soap.wsdl_cache_enable', '0');
$client = new SoapClient('http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl');
$data = $client->GetQuote(array('StockSymbol' => 'TEST_STR','LicenseKey' => 'TEST_STR'));
print_r($data);

将TEST_STR替换为您的数据