Pablo
Pablo

Reputation: 41

Soap SOAP_COMPRESSION_GZIP verfication if it works

Using php5 and I'm making soap requests to a webservice based on a wsdl that doesn't use the Header element.

Everything, I've been asked now to use gzip compression on my soap requests.

So my client now looks like this:

$client = new SoapClient('xxxxx.wsdl', 
                         array('compression'=> 
                                     SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 
                                'trace' => 1, )
                          ); 

I've googled a bit and I found sites saying I should also add the gzip compression level (add | 9) after SOAP_COMPRESSION_GZIP, but when I do that I get a soap fault back

"Content is not allowed in prolog"

So I dropped the pipe 9)

Question: Ss I´m no expert in soap, with above notation I don't get any errors on the outbound xml request nor on the return request. How do I know if my gzip compression is working and if so is being acknowledged on the other side?

Upvotes: 4

Views: 4793

Answers (1)

Dobromir Velev
Dobromir Velev

Reputation: 520

You can check SoapClient::__getLastRequestHeaders and check the content-encoding and content-length headers. If the Request is compressed the Content-Length value should be smaller than the payload size

If the web service is not on HTTPS you can also run a packet sniffer like WireShark and capture the request and see exactly what was transfered.

Upvotes: 2

Related Questions