我正在使用第三方SOAP API来获取用户详细信息
$wsdl = 'https://sample.ifuture.com/sites/sample.xxxx.com/api/isession.php?wsdl';
$client = new SoapClient($wsdl, array ( 'username'=>'testusername', 'password'=>'testpassword'));
print_r($client->__getFunctions());
当我使用SoapClient()
时,我成功连接到WSDL,最后一个语句返回WSDL的函数列表。
结果
Array
(
[0] => boolean iLoggedOn(string $session)
[1] => boolean iLogOff(string $session)
[2] => boolean iLogOn(string $session, string $username, string $password)
[3] => boolean iPasswd(string $session, string $username, string $password)
[4] => list(boolean $return, string $message) iSync(string $username, string $action, string $values)
)
现在我正在尝试使用SOAP __Call()
来调用soap方法
$param = array(
"sessionid" =>"12345678900987654321abcisfetul12",
"username" =>"test",
"password"=>"test");
$client->__Call('iLogOn', $param);
执行上述语句会产生如下所述的错误
Fatal error: Uncaught SoapFault exception: [HTTP] Authorization Required in /opt/lampp/htdocs/demo/saop/index.php:79 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://sample....', 'https://sample....', 1, 0) #1 /opt/lampp/htdocs/demo/saop/index.php(79): SoapClient->__call('iLogOn', Array) #2 {main} thrown in /opt/lampp/htdocs/demo/saop/index.php on line 79
期待合适的解决方案。