Closed timint closed 6 years ago
+1 more case today where this had become handy
An example of how I use to log raw HTTP data from the SOAPClient
class SveaSOAPClient extends SOAPClient {
private $_request = array();
private $_response = array();
public function __construct($wsdl, $options=array()) {
$options['trace'] = true;
$options['exceptions'] = true;
parent::__construct($wsdl, $options);
}
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
$timestamp_start = time();
$microtime_start = microtime(true);
try {
$result = parent::__doRequest($request, $location, $action, $version, $one_way);
} catch (SoapFault $fault) {
throw new Exception($fault->getMessage());
}
// PHP Bug - parent::__getLastResponse() returned null, however print_r($result, true) returned xml content
$response_body = print_r($result, true);
$this->_http_request = array(
'timestamp' => $timestamp_start,
'head' => parent::__getLastRequestHeaders(),
'body' => functions::xml_pretty_print(parent::__getLastRequest()),
);
$this->_http_response = array(
'timestamp' => time(),
'head' => parent::__getLastResponseHeaders() . PHP_EOL,
'body' => functions::xml_pretty_print($response_body),
'data_amount' => strlen(parent::__getLastResponseHeaders()) + strlen($response_body),
'duration' => round(microtime(true) - $microtime_start, 3),
);
return $result;
}
}
+1 for a case earlier this week
+1 for another client case today
Added in 3.6.0, soap requests now contains logs if the user decides to enable them
For debug and support matters it's proven to (many times over) be helpful if we could access some sort of raw http log of the Request and Response:
E.g.
$swp->getLastHTTPDebug();
I would easier get an immediate understanding of what might have gone wrong during communication.