A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearFile from SOAP, how to save? - page 1
User InfoPosts
File from SOAP, how to save?#1
I am working with a client on getting a gzip from their webservice. I am able to get a response with my following call:

$response = $client->call((branchzipdata(, $param);
$filename = "test.gzip";
if (!$handle = fopen($filename, (a()) {
echo "Cannot open file ($filename)";
exit;
}

if (fwrite($handle, $response) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}


Now when I attempt to write that a file, such as (test.gzip(, I am unable to open it afterwards... most likely because I am doing something horrible wrong. Any insight would be appreciated.

EDIT:

For some reason I was saving the file as (.gzip( instead of (.gz(... So in order to have it work I now have:

$response = $client->call((call(, $param);
$content = base64_decode($response);
$filename = "output_zip.gz";
if (!$handle = fopen($filename, (w()) {
echo "Cannot open file ($filename)";
exit;
}

if (fwrite($handle, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
fclose($handle);
echo system("gzip -d $filename");

posted date: 2009-04-09 13:30:00


Re: File from SOAP, how to save?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-09 13:30:01


Re: File from SOAP, how to save?#3
(Edited based on the comments)If the return value is base64-encoded, you need to base64-decode it before you write it to the file. Alternatively you could write it out to a file which you then base64-decode to another file before trying to open it, but that seems a bit pointless compared with just decoding it when you first get it.

posted date: 2009-04-09 13:32:00


Re: File from SOAP, how to save?#4
Sorry, forgot to include that piece of code, but I am actually closing the handle. From the more I read I am thinking I am just approaching this in the wrong way. I have yet to deal with soap.

posted date: 2009-04-09 13:40:00


Re: File from SOAP, how to save?#5
What happens when you try to read the file? Can you actually open it, but it's not a gzip file? Is it base64-encoded by any chance?

posted date: 2009-04-09 13:56:00


Re: File from SOAP, how to save?#6
I am no longer at work, but yes, it is base64-encoded. The part that confused me was do I decode it before I write the contents to the test.gzip or decoded the contents afterwards? I guess I am just confused when it comes to handling the response I get from the soap request. Thanks for your help!

posted date: 2009-04-09 16:28:00


Re: File from SOAP, how to save?#7
Base64-decode it before you write it to test.gzip.

posted date: 2009-04-09 22:27:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.