By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

recieve zip file via xml

P: n/a
Hey guys,

I am connecting to a supllier via SOAP that sends me with the price
list zipped inside an xml message. I can connect and I can retrieve
the xml information (see the message, save the content, etc...)
however i am unable to unzip the information contained in the tag

here is my code:

<code>
<?php

$client = new SoapClient("mywsdl service",array('trace' =1));

$call = $client->__soapCall("Cliente",
array('Cliente'=>array('ncliente'=>"user",'pss'=>" password")));

//Some debugging

echo("\r\nCabecera de la solicitud:\n" .$client-
>__getLastRequestHeaders());
echo("\r\nSolicitud:\n".$client->__getLastRequest());

echo("\r\nCabecera de Respuesta:\n" . $client-
>__getLastResponseHeaders());
echo ("\r\nRespuesta:" . $client->__getLastResponse());
$myFile = "prueba.zip";
$fh = fopen($myFile, 'wb');

fwrite($fh, $call->ClienteRespuesta);

fclose($fh);

?>
</code>

When i try to open the file with zip i get an error. the file has
1024kb so I know there is info in there but i just dont know how to
access it. I have also tried to base64_decode manually before the SOAP
parses the info with no luck.

Thank you for any help.

Dec 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
$myFile = "prueba.zip";
$fh = fopen($myFile, 'wb');

fwrite($fh, $call->ClienteRespuesta);
If this really is a SOAP service, it will contain XML. There are a few
ways to send binaries with XML, but a SOAP service will never send a
pure binary as far as I know.
When i try to open the file with zip i get an error. the file has
1024kb so I know there is info in there but i just dont know how to
access it. I have also tried to base64_decode manually before the SOAP
parses the info with no luck.
Just take a look at the saved file. If there is any base64 encoded data
inside, it is given within XML tags. So again, it is not the whole response.

But there is also the possibility that it is an attachment. In that
case, the response is a multipart download. I do not know the SOAP
library enough to be able to tell you if it can handle that. If it can
(which would not surprise me), there is probably a method of the client
object that gives you access to the attachments.

Good luck and a nice christmas,
Dikkie
Dec 24 '07 #2

P: n/a
Thanks Dikkie,

With soap i do retrieve an xml file which i save into $call. I can
reference the tags directly, since the information I want is in the
ClienteRespuesta tag, I write it directly into the file.
fwrite($fh, $call->ClienteRespuesta);
Just take a look at the saved file. If there is any base64 encoded data
inside, it is given within XML tags. So again, it is not the whole response.
AFAIK soap decodes base64 when you access the xml tag. in any case i
have tried decoding manually by debugging the response with the same
result. As you can see in the code above I am extracting the data from
the tags, so there are no tags in the file.

If the file is an attachment how would you handle with xml, i havent
seen anything in soap.
Thanks again and Happy Christmas to you too.
Dec 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.