0
我正在調用第三方Web服務以獲取用戶提供的憑證詳細信息。以下是我的Soap客戶端請求。如何在PHP中處理SoapClient錯誤
$client = new \SoapClient($url, array("exception" => 0));
$auth = '
<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>' . $userName . '</wsse:Username>
<wsse:Password>' . $password . '</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>';
$authvalues = new \SoapVar($auth, XSD_ANYXML);
$header1 = new \SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvalues, true);
$header2 = new \SoapHeader("http://xmlns.myweb.com/FulfillProductRequest/V1", "v1");
$header3 = new \SoapHeader("http://xmlns.myweb.com/ParameterType/V2", "v2");
$header4 = new \SoapHeader("http://xmlns.myweb.com/RequestHeader/V3", "v3");
$header = array();
$header[] = $header1;
$header[] = $header2;
$header[] = $header3;
$header[] = $header4;
$client->__setSoapHeaders($header);
$res = $client->FulfillProduct($FulfillProductRequest);
當我打電話的WSDL,如果我得到成功響應,那麼就沒有問題。
但是,如果在soapFault中出現任何錯誤,那麼我的代碼會顯示致命錯誤。
任何人都有任何想法如何處理SoapFault PLZ份額。
非常感謝。
我正在使用try catch塊。但無法處理致命的錯誤。致命錯誤:Unocaught SoapFault異常:[env:Server] XXXXXXXXXXXXX XXX XXXXX – MANOJ
在您的SoapClient參數中,您已設置'exceptions => 0'。刪除它,因爲它阻止了SoapClient拋出異常。 –
刪除後也不起作用。我得到了同樣的錯誤(致命錯誤) – MANOJ