我需要使用这个xml文件: http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL
连接 GetTopGainers 方法 我使用这段代码:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL";
$parameters = array("Username"=>"xxxx","Password"=>"xxxx","ID"=>"xxxxx");
$client = new SoapClient($wsdl_path, array('trace' => 1));
try {
$result = $client->GetTopGainers($parameters);
print_r($result);
}
catch (SoapFault $exception) {
echo $exception;
}
?>
但我收到以下错误:
SoapFault exception: [soap:Server] Server was unable to process request.
---> Object reference not set to an instance of an object. in
C:\wamp\www\soap\soap.php:24 Stack trace: #0
C:\wamp\www\soap\soap.php(24): SoapClient->__call('GetTopGainers', Array)
#1 C:\wamp\www\soap\soap.php(24): SoapClient->GetTopGainers(Array) #2
{main}
任何帮助将不胜感激。 感谢
答案 0 :(得分:0)
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "URL";
$parameters = array("Username"=>"xxx","Password"=>"xxx","ID"=>"xxx");
$header = new SOAPHeader('Namespace', 'Auth', $parameters);
$client = new SoapClient($wsdl_path);
$client->__setSoapHeaders($header);
try {
$topGainers = $client->GetTopGainers(); // Top Gainers
echo"<pre>";
print_r($topGainers);
echo"</pre>";
}
catch (SoapFault $exception) {
echo $exception;
}
?>