You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-user@xml.apache.org by Tom Content <to...@gmx.de> on 2002/04/04 14:37:57 UTC

Receive binary data with client ?

Hi all,

i have a little big Problem with the xml-rpc-Client. When i try to reach a
Zope-System, which includes a xml-rpc-Server on Phyton-Base, i cannot
receive
binary data.
It is no problem to receive a html-Document, therefore my little
Java-Programm runs well.

Part of the Java-Progi.:
........
XmlRpcClient server = new XmlRpcClient("http://localhost:8080/tom/");
server.setBasicAuthentication("xx","xx");
// Empty Parameter list.
Vector params = new Vector();
// Server Call and Printout Result
String result = (String) server.execute("tom_htm",params);
System.out.println("Inhalt von tom_htm: " + result);
            } catch (XmlRpcException exception) {......}
........

The Program prints out the Source Code of the tom_htm-document, which is ok.
In the same Folder (/tom) is a beautiful Picture (Pic1). When i try
now to change the line:
String result = (String) server.execute("tom_htm",params);
into 
String result = (String) server.execute("pic1",params);
 --> I only get an error :
JavaClient: XML-RPC Fault #-1: org.apache.xmlrpc.XmlRpcException: Unexpected
Zope exception: cannot marshal <extension class
Acquisition.ImplicitAcquirerWrapper at 00C25140> objects

How can i receive the Picture or any other binary data ? How can i tell my
Java-Client to receive Binary-Data, or do you think it could be the Problem
of
the Server (Is there a Client-parameter where i have to tell the Server:Send
a
binary chunk) ?? 
Thank you in advance for your help,

Tom

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


Re: Receive binary data with client ?

Posted by Phil Wilson <pi...@hotmail.com>.
Hi Tom,

In order to transfer binary data (like an image) through XML-RPC you have to
encode it to base64-characters on the server and then the client can decode
it back into an array of bytes which you can then write to a file.

In the Apache library this is done through the Base64.encode and
Base64.decode methods (check the API for more details), and your Zope server
probably has similar methods.

Your server should be converting binary files to Base64 before you can do
anything with it client-side though. If you have access to the server code
then you could change it to transmit all files in this way (which is a bit
of a kludge, but should mean that any file transferred will arrive as it
exists on the server).

hope this helps a little,

viel Glück!

Phil


> Hi all,
>
> i have a little big Problem with the xml-rpc-Client. When i try to reach a
> Zope-System, which includes a xml-rpc-Server on Phyton-Base, i cannot
> receive
> binary data.
> It is no problem to receive a html-Document, therefore my little
> Java-Programm runs well.
>
> Part of the Java-Progi.:
> ........
> XmlRpcClient server = new XmlRpcClient("http://localhost:8080/tom/");
> server.setBasicAuthentication("xx","xx");
> // Empty Parameter list.
> Vector params = new Vector();
> // Server Call and Printout Result
> String result = (String) server.execute("tom_htm",params);
> System.out.println("Inhalt von tom_htm: " + result);
>             } catch (XmlRpcException exception) {......}
> ........
>
> The Program prints out the Source Code of the tom_htm-document, which is
ok.
> In the same Folder (/tom) is a beautiful Picture (Pic1). When i try
> now to change the line:
> String result = (String) server.execute("tom_htm",params);
> into
> String result = (String) server.execute("pic1",params);
>  --> I only get an error :
> JavaClient: XML-RPC Fault #-1: org.apache.xmlrpc.XmlRpcException:
Unexpected
> Zope exception: cannot marshal <extension class
> Acquisition.ImplicitAcquirerWrapper at 00C25140> objects
>
> How can i receive the Picture or any other binary data ? How can i tell my
> Java-Client to receive Binary-Data, or do you think it could be the
Problem
> of
> the Server (Is there a Client-parameter where i have to tell the
Server:Send
> a
> binary chunk) ??
> Thank you in advance for your help,
>
> Tom
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
>

Re: Receive binary data with client ?

Posted by Phil Wilson <pi...@hotmail.com>.
Hi Tom,

In order to transfer binary data (like an image) through XML-RPC you have to
encode it to base64-characters on the server and then the client can decode
it back into an array of bytes which you can then write to a file.

In the Apache library this is done through the Base64.encode and
Base64.decode methods (check the API for more details), and your Zope server
probably has similar methods.

Your server should be converting binary files to Base64 before you can do
anything with it client-side though. If you have access to the server code
then you could change it to transmit all files in this way (which is a bit
of a kludge, but should mean that any file transferred will arrive as it
exists on the server).

hope this helps a little,

viel Glück!

Phil


> Hi all,
>
> i have a little big Problem with the xml-rpc-Client. When i try to reach a
> Zope-System, which includes a xml-rpc-Server on Phyton-Base, i cannot
> receive
> binary data.
> It is no problem to receive a html-Document, therefore my little
> Java-Programm runs well.
>
> Part of the Java-Progi.:
> ........
> XmlRpcClient server = new XmlRpcClient("http://localhost:8080/tom/");
> server.setBasicAuthentication("xx","xx");
> // Empty Parameter list.
> Vector params = new Vector();
> // Server Call and Printout Result
> String result = (String) server.execute("tom_htm",params);
> System.out.println("Inhalt von tom_htm: " + result);
>             } catch (XmlRpcException exception) {......}
> ........
>
> The Program prints out the Source Code of the tom_htm-document, which is
ok.
> In the same Folder (/tom) is a beautiful Picture (Pic1). When i try
> now to change the line:
> String result = (String) server.execute("tom_htm",params);
> into
> String result = (String) server.execute("pic1",params);
>  --> I only get an error :
> JavaClient: XML-RPC Fault #-1: org.apache.xmlrpc.XmlRpcException:
Unexpected
> Zope exception: cannot marshal <extension class
> Acquisition.ImplicitAcquirerWrapper at 00C25140> objects
>
> How can i receive the Picture or any other binary data ? How can i tell my
> Java-Client to receive Binary-Data, or do you think it could be the
Problem
> of
> the Server (Is there a Client-parameter where i have to tell the
Server:Send
> a
> binary chunk) ??
> Thank you in advance for your help,
>
> Tom
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
>