[英]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.