RE: [PEAR] Image over web service
| From: | Mike Carter | Date: | Tue, 25 Mar 2003 15:37:29 +0000 |
| Subject: | RE: [PEAR] Image over web service | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4416@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Steve Fisk [mailto:sfisk@quantiv.com]
>
> I have also posted this on the soap list but is more a php question.
>
> I am attempting to send an image over a web service from one
> server to another. On one end is a C#.Net webservice and
> then a client on my side. The C# web service sends me the
> image as a byte stream over SOAP - does anyone know how to
> decode the byte stream back into an image? If so do I need
> any extra packages to do this? Or are there functions in
> PEAR that can do it?
Try:
<?php
/*
* This script simulates an image file. It can be referenced within HTML as
if it
* was an image of any type (gif, jpeg, png).
*
* INPUTS:
* pic picture number to pass to web service
*/
// --- If no number is specified
if(!isset($pic)) {
$pic = 1;
// return a "not available" image really?
}
// --- Collect the specified image from the image database webservice
$client = new WebService_Service1_Service1Soap();
$result = $client->GetImage(0, 0, $pic);
// --- If there is a valid result (ie not a SOAP Fault)
if($result) {
echo base64_decode($result);
}
exit;
?>
In the above code, the "$client->GetImage()" is the webservice method
returning the byte stream.
The "if($result)" should really check that the $result is not a SOAP Fault,
but I'm not sure how to do that - suggestions please? :-)
It may be better to send the image as a MIME attachment - not sure what the
correct procedure is for this.
- Mike Carter
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________