views:

24

answers:

1

I am on a linux server connecting to a webservice via PHP/Soap.

The problem is that a method is zipping the response via SharpZipLib. So all I get in return is a garbled string.

Does anyone know of a way to unzip this with PHP or JS?

Thanks!

Update:

This is the compressed test data that gets returned:

UEsDBC0AAAAIAI5TWz3XB/zi//////////8EABQAZGF0YQEAEADWAgAAAAAAABYBAAAAAAAAfZLvToNAEMTnUXyDatXEDxcS/3zxizH6BBVESaESKFHf3t+cOWgtNhcuYXd2Zndug570qjdV6rVVpxV3pQ9tlCnohv+ab6Mc1J0G7kynZBb/5IKeYTDLAGOm28hVwtmpobqItfuYACpp1Ki42jobOGqO1eYRIXI2egHfofeOTqt7OE6o8QQdmbnpjMm01JXOdcG5ZKplVDpeEeBr6LCir2umKaJCj3ZSbGPEE3+Nsd/57fADtfYhoRtwZqmJ/c3Z+bmaHl9Kzq6CX20bWRJzjvMNbtjZ71Fvtdfz2RjPY/2ESy54ExJjC6P78U74XYudOaw2gPUOTSyfRDut9cjLmGma2//24TBTwj85573zDhziFkc29wdQSwECLQAtAAAACACOU1s91wf84v//////////BAAUAAAAAAAAAAAAAAAAAAAAZGF0YQEAEADWAgAAAAAAABYBAAAAAAAAUEsFBgAAAAABAAEARgAAAEwBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

+1  A: 

Chances are, it's using gzip. You should look into PHP Zlib and the gzdecode or gzdeflate methods. You'll probably need to look at the Content type header or another response header.

Something you can try is also setting an Accept header in the web service request that tells the service you don't know how to deal with compression. If it's a proper service, it will honor the request.

EDIT Looking at the .pdf, they're sending the data as a zip archive - so you need to find a PHP lib that deals with in memory zip archives. The C# code they use to decode it is pretty straightforward - they just read all the entries in the archive and expand them. You can try storing it as an in memory buffer using a PHP wrapper along with PHP Zip.

Did you try setting an Accept Header that asks for no compression?

SB
Although I'd hope the client is smart enough to automatically deal with HTTP compression. Guess not ... or it's a zip inside the stream.
pst
Thanks! I have tried gzdeflate and gzuncompress but both seem to return data errors or garbled text. Could this have to do with the level of compression? Warning: gzuncompress() [function.gzuncompress]: data error in /home/npculti/public_html/unzip/unzip.php on line 6
Fostah
Also I get a function not found on gzdecode, so if that was it I would just need to install it and try it. I have attached the compressed string I get to the question as well. Thanks for any help!
Fostah
I just tried a gzdecode function I found and it returns the same compressed string. function gzdecode($data){ $g=tempnam('/tmp','ff'); @file_put_contents($g,$data); ob_start(); readgzfile($g); $d=ob_get_clean(); return $d;}
Fostah