Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 views
in Technique[技术] by (71.8m points)

c# - Decompress SharpZipLib string in php or JS?

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=

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...