PHP Soap 请求在 SoapUI 中工作,但在 PHP 中不起作用


PHP Soap Request works in SoapUI but not in PHP

我必须执行很多SOAP请求。所以我在 SoapUI 中构建了一个请求,它运行良好。我点击了播放按钮并得到了预期的结果。

现在我想使用 PHP 创建相同的 SOAP 请求,但这不起作用。与 WDSL 文件的"连接"有效。当我做__getFunctions__getTypes时,它按预期工作。

PHP代码:

$wdsl = "http://MYSERVER/v2?wsdl";        
$soap = new SoapClient($wdsl, array('soap_version'=>SOAP_1_2,"trace"=>1,'encoding' => 'UTF-8');
try {
    $x =$soap->getHotelProduct($req);
} catch (SoapFault $e) {
    echo $e->getMessage();
}
var_dump($x); 

$req是(在 SoapUI 中)工作请求。

执行脚本时出现的错误是:

object(stdClass)#2 (2) { ["Error"]=> object(stdClass)#3 (2) { ["_"]=> string(40) "The request contains an unknown AuthKey." ["Code"]=> int(1) } ["Success"]=> bool(false) }  

但是:AuthKey是绝对正确的!我什至从它工作的SoapUI复制并粘贴了它。

希望这里的任何人都可以帮助我。

请尝试以下操作。尝试使用 __soapCall();

try
{       
   $x =$soap->__soapCall("getHotelProduct",array($req));
   $x = (array) $x;      //convert to array
}
// ..... //
var_dump($x);