[英]PHP soap client call stops script
以下问题使我发疯:
我已通过WSDL和p12证书连接到SOAP WS。 如果方法不正确或缺少参数,我可以调用某些东西并获取异常:
"Function ("Test1") is not a valid method for this service"
"SOAP-ERROR: Encoding: object has no 'message' property"
但是,如果一切都正确(我认为),脚本将停止
try{
$client = new SoapClient(
$soapUrl,
array(
'ssl' => array(
'cert' => $cert_file,
'certpasswd' => $cert_password),
'trace' => 1,
'exceptions' => 0
)
)
);
$uuid = gen_uuid();
$SendValue = array('transaction' => Array('uuid'=>$uuid),
'message' => '-test message-',
'delay' => 0,
throwException => 1,
forceRollback => 0);
echo "<br>";
// var_dump($SendValue);
echo "Test Start - "; // this is printed
$result = $client -> Test($SendValue);
echo " - Test Ende"; // this is not printed anymore and all the below
echo "<br>OK - Request:\n" . $client->__getLastRequest(). "!\n";
echo "<pre>";
print_r($result);
echo "</pre>";
//-----------------------------------------------------------
echo "<h1>EOF</h1>";
}catch(\Exception $exception)
{
echo "Did not work...";
var_dump($exception);
echo "Request:\n" . $client->__getLastRequest() . "\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";
}
echo "this is not printed";
有什么建议吗? 非常感谢预先。
看起来您将trace
选项放置在配置阵列中的错误位置。 而不是
array(
'ssl' => array(
'cert' => $cert_file,
'certpasswd' => $cert_password,
'trace' => 1,
'exceptions' => 0
)
)
它应该是
array(
'ssl' => array(
'cert' => $cert_file,
'certpasswd' => $cert_password,
)
'trace' => 1,
'exceptions' => 0
)
有效的未设置trace
选项(将其放置在错误的位置时,使用后备默认值0
)将导致__getLastRequest()
不可用,因此您可能会收到“调用未定义的方法错误”的消息。
您没有看到此错误的最可能原因是运行时php配置,该配置使您无法看到错误消息。 请参阅PHP的白屏死机,以了解如何查看错误。
也可能是SoapClient
引发了不同类型的异常,而不是\\SoapFault
。 将该类型更改为\\Exception
,看看是否有任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.