SoapClient->__getLastResponse()

(no version information, might be only in CVS)

SoapClient->__getLastResponse() --  Returns last SOAP response.

说明

class SoapClient {

string __getLastResponse ( void )

}

注: This method works only if the SoapClient object was created with the trace option.

返回值

The last SOAP response.

范例

例子 1. SoapClient->__getLastResponse() example

<?php
$client
= SoapClient("some.wsdl", array('trace' => 1));
$result = $client->SomeFunction();
echo
"RESPONSE:\n" . $client->__getLastResponse() . "\n";
?>


add a note add a note User Contributed Notes
ceo at l-i-e dot com
05-Jan-2006 05: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
05-Jan-2006 05: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