【发布时间】:2014-10-06 09:37:26
【问题描述】:
我正在使用 PHP SoapClient 对以下 URL 使用肥皂调用请求。
https://stagingxml.tamarindtours.in/Version1.0/BaseDetails.svc?wsdl
我使用了以下代码。
$HeaderSecurity = array("UsernameToken"=>array("Username"=>"xxx",
"Password"=>"xxx",
)
);
$client = new SoapClient('https://stagingxml.tamarindtours.in/Version1.0/BaseDetails.svc?wsdl',array('trace' => 1));
$header[] = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security",$HeaderSecurity);
$client->__setSoapHeaders($header);
//$client->__setLocation("https://YourTargetLocation/"); if you have wsdl file you don't need to use this line
$REsponse = $client->GetCountries();
我收到以下错误。
致命错误:未捕获的 SoapFault 异常:[a:InvalidSecurity] An 验证消息的安全性时发生错误。在 /opt/lampp/htdocs/wssoap.php:148 堆栈跟踪:#0 /opt/lampp/htdocs/wssoap.php(148): SoapClient->__call('GetCountries', 数组)#1 /opt/lampp/htdocs/wssoap.php(148): SoapClient->GetCountries() #2 {main} 抛出 /opt/lampp/htdocs/wssoap.php 在第 148 行
你能帮帮我吗?谢谢。
【问题讨论】:
-
我会检查实际的请求和响应。使用通过“trace=true”提供的 __get* 函数。另外,但这可能是一个红鲱鱼,即使使用 HTTPS,我也不必使用 __setSoapHeaders()!
标签: php soap-client