You don't need to surround SoapClient in a try-catch block. Just set the "exceptions" option to false, and the SoapFault instance will be returned instead of thrown.
SoapClient::__getLastResponse
(PHP 5 >= 5.0.1)
SoapClient::__getLastResponse — 直近の SOAP レスポンスを返す
説明
public string SoapClient::__getLastResponse
( void
)
直近の SOAP レスポンスで受信した XML を返します。
注意:
このメソッドは、オプション trace を指定して SoapClient が作成されている場合のみ使用可能です。
パラメータ
この関数にはパラメータはありません。
返り値
直近の SOAP レスポンスを XML 文字列で返します。
例
例1 SoapClient::__getLastResponse() の例
<?php
$client = SoapClient("some.wsdl", array('trace' => 1));
$result = $client->SomeFunction();
echo "Response:\n" . $client->__getLastResponse() . "\n";
?>
参考
- SoapClient::__getLastResponseHeaders() - 直近の SOAP レスポンスヘッダを返す
- SoapClient::__getLastRequest() - 直近の SOAP リクエストを返す
- SoapClient::__getLastRequestHeaders() - 直近の SOAP リクエストヘッダを返す
bshafs at gmail dot com
22-Jun-2011 12:45
ceo at l-i-e dot com
04-Jan-2006 01:31
D'oh!
That example needs:
$soapClient = new SoapClient($url, array('trace'=>1));
to turn ON tracing in the first place.
ceo at l-i-e dot com
04-Jan-2006 01:30
You almost for sure will need to wrap a try/catch block around your SOAP call in order to use these to debug something that's not working.
Otherwise, PHP throws a fatal error before you can execute this function.
For example:
<?php
$soapClient = new SoapClient($url);
echo htmlentities($soapClient->__getFunctions());
//Assume that has output 'someFunction' (among others)
try {
$results = $soapClient->someFunction(...);
}
catch (SoapFault $soapFault) {
var_dump($soapFault);
echo "Request :<br>", htmlentities($soapClient->__getLastRequest()), "<br>";
echo "Response :<br>", htmlentities($soapClient->__getLastResponse()), "<br>";
}
?>
Without try/catch, your just get the Fatal Error and PHP commits suicide before you can call __getLastRequest/__getLastResponse
