【发布时间】:2019-05-05 17:38:32
【问题描述】:
以下问题让我发疯:
我使用 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";
有什么建议吗?非常感谢。
【问题讨论】:
-
不幸的是,您会发现一些 Soap 错误在 PHP 中是无法捕获的。就是这样......我想我记得在某处读过你可以创建一个可能能够处理它的自定义错误处理程序,但我想我记得如果端点关闭,SoapClient 将抛出一个致命错误(无法捕捉)。可能没用,但我还是想提一下。
标签: php soap wsdl certificate signed