The service code you pasted below shows
// Use the request to (try to) invoke the service
//$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';
//$server->service($HTTP_RAW_POST_DATA);
If you really have those lines commented, your service will not do
anything. The $server->service call is where the SOAP call gets
handled.
Scott Nichol
----- Original Message -----
From: "Stefan Schwarzer" <stefan.schwarzer@xxxxxxxxxxxx>
To: "Scott Nichol" <snicholnews@xxxxxxxxxxxxxxx>
Cc: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, April 17, 2007 3:52 AM
Subject: Re: [Nusoap-general] NuSoap & Binary Attachments
> Hmmm.... in principal it should be clear by now. But it still doesn't
> work. I did as you indicated (see code below), but it returns an
> empty page/image. Do you have any idea why this would be so?
>
>
> CLIENT:
>
> <?php
> // includes nusoap classes
> include('nusoap.php');
>
> // creates an instance of the SOAP client object
> $wsdl = 'http://my-url/graph_ws.php?wsdl';
>
> $client = new soapclient($wsdl, 'wsdl');
>
> $result = $client->call('getFile', array('filename' =>
> 'graphexe.gif'));
>
> header("Content-Type: image/gif");
> header("Content-Length: " . strlen($result));
> echo $result;
> ?>
>
>
>
> SERVER:
>
> // Define the method as a PHP function
> function getFile($filename) {
> global $HTTP_SERVER_VARS;
> if ($filename != 'php.gif' && $filename != 'getfile1.php') {
> return new soap_fault('SOAP-ENV:Client', 'getfile1', 'Unsupported
> file name', array('filename' => $filename));
> }
> $path = '/www/geodataportal/htdocs/webservices/' . $filename;
> $handle = fopen($path, "rb");
> $contents = fread($handle, filesize($path));
> fclose($handle);
> return base64_encode($contents);
> }
> // Use the request to (try to) invoke the service
> //$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
> $HTTP_RAW_POST_DATA : '';
> //$server->service($HTTP_RAW_POST_DATA);
>
>
>
> On Apr 16, 2007, at 4:55 PM, Scott Nichol wrote:
>
>> filesize() is not going to find your file, so nothing gets read.
>> You need to do
>>
>> $path = '/www/geodataportal/htdocs/webservices/' . $filename;
>> $handle = fopen($path, "rb");
>> $contents = fread($handle, filesize($path));
>> fclose($handle);
>> return base64_encode($contents);
>>
>> Scott Nichol
>>
>> ----- Original Message ----- From: "Stefan Schwarzer"
>> <stefan.schwarzer@xxxxxxxxxxxx>
>> To: "Scott Nichol" <snicholnews@xxxxxxxxxxxxxxx>
>> Cc: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
>> Sent: Monday, April 16, 2007 10:45 AM
>> Subject: Re: [Nusoap-general] NuSoap & Binary Attachments
>>
>>
>>>
>>>>
>>>>> // base64_decode here ????
>>>>>
>>>>> $fp = fopen("/www/geodataportal/temp/graph_test.gif", "w"); //
>>>>> do I need to write the content of $result into an image?
>>>>> fwrite($fp, $result);
>>>>> fclose($fp);
>>>>>
>>>>> echo '<img src="http://geodata.grid.unep.ch/temp/graph_test.gif"
>>>>> alt="" />'; // ... and then load it as graphic?
>>>>
>>>> You do not need to base64_decode; NuSOAP will do that for you.
>>>>
>>>> The method you specify will work if you want to have a script that
>>>> returns a page that has the img. You can also, of course, have a
>>>> PHP script that returns the GIF it gets from the web service.
>>>> After $result = $client->call(...), the script would set the
>>>> Content-Type header it returns to image/gif and return the result,
>>>> something like
>>>>
>>>> header("Content-Type: image/gif");
>>>> header("Content-Length: " . strlen($result));
>>>> echo $result;
>>>
>>> Scott, thanks for that clarification.
>>>
>>> Do I have to change something within the servers' code to get it
>>> working? In the moment I get a blank image as result....
>>>
>>> $handle = fopen('/www/geodataportal/htdocs/webservices/' .
>>> $filename, "rb");
>>> $contents = fread($handle, filesize($filename));
>>> fclose($handle);
>>> return base64_encode($contents);
>>>
>>>
>>>
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
|