how to get the raw http data - request and response ?
michabbb opened this issue · comments
hi,
i searched the whole repository but was unable to find anything that helps, sorry.
so I have to ask: what´s the easiest way to log the full HTTP request and response ?
i don´t really understand how I get there. the logsubscriber only shows me the request
as an object, but I need to see the RAW data to understand when things go wrong.
thanks for any help!!!
Hello,
You can either:
- Use the Httplug logger plugin. Example see docs : https://github.com/php-soap/psr18-transport#httplug-middleware
- Use the TracableTransport. Example see docs : https://github.com/php-soap/ext-soap-engine/#example-usage
thanks for your feedback!
I do see that the logger plugin seems to be the right place for me, but to be honest, I don't see anything (I have read the readme) at TracableTransport package where to get that, do you have maybe 3 lines of code to help me understanding? sorry.
Indeed, the HTTP logger is also my favourite tool for this purpose.
About traceable transport:
It is a wrapper around another transport (e.g. the PSR-18 transport) that collects the HTTP request / response body from the available methods in PHP's SoapClient. It does not include any changes made by HTTP middleware though.
https://github.com/php-soap/ext-soap-engine/blob/main/src/Transport/TraceableTransport.php
use Soap\ExtSoapEngine\Transport\TraceableTransport;
$transport = new TraceableTransport(
$abusedClient,
new ExtSoapClientTransport($abusedClient)
);
// Use this transport inside your $engine
$result = $engine->request('SomeMethod', [(object)['param1' => true]]);
// Collecting last soap call:
var_dump($transport->collectLastRequestInfo());
okay, got it, thanks! anyway, I guess I will try to get my Infos from the logger plugin