axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: attachements and headers
Date Fri, 16 Aug 2002 13:41:34 GMT

I hope I'm not missing the point here, but you are talking about e.g. binary (or text) file

If the server-side is controlled by you, this should work: I have created my own datatype
for sending binary attachments like this in java (I am not using custom headers at all):

//----------------------START CODE------------------------------------
package no.geomatikk.soap.datatypes;
public class Base64File {
    private String name;
    private byte[] data;

    public String getName() { return name; }
    public void setName(String name) { = name; }

    public byte[] getData() { return data; }
    public void setData(byte[] data) { = data; }
//----------------------END CODE--------------------------------------

I run this through Java2WSDL and get:

   <complexType name="Base64File">
     <element name="name" nillable="true" type="soapenc:string"/>
     <element name="data" type="soapenc:base64"/>

You can generate client-side classes with WSDL2Java from this, and get client code you don't
need to edit manually.

This works with Axis client (also when sending an array of Base64File), and it should work
with .NET also (not tested yet).

The reason I use this approach is that I have heard that attachments are not very interoperable
for the time being. Byte arrays are automatically sent/received BASE64 coded, so it is a OK
way to do things.

Any comments?

Eirik Wahl
Bravida Geomatikk AS

-----Original Message-----
From: []
Sent: 16. august 2002 14:55
Subject: Re: attachements and headers

I'm in the process of implementing JAX-RPC attachments in WSDL2Java/Java2WSDL. I'm not done
yet so don't expect too much, but if you grab the latest nightly build and just use DataHandler
you should be OK.

For example, if you started with the Java method:

public DataHandler echoDataHandler(DataHandler in0) throws RemoteException;

Java2WSDL would give you the following WSDL:

<wsdl:definitions ... xmlns:apachesoap="" ...

<wsdl:message name="echoDataHandlerRequest">
<wsdl:part name="in0" type="apachesoap:DataHandler"/>
<wsdl:message name="echoDataHandlerResponse">
<wsdl:part name="echoDataHandlerReturn" type="apachesoap:DataHandler"/>

<wsdl:operation name="echoDataHandler" parameterOrder="in0">
<wsdl:input message="intf:echoDataHandlerRequest" name="echoDataHandlerRequest"/>
<wsdl:output message="intf:echoDataHandlerResponse" name="echoDataHandlerResponse"/>

And WSDL2Java would take this and give you the appropriate mappings.

Note that this is NOT interoperable WSDL. We've introduced an AXIS-specific type: apachesoap:DataHandler.
The reason we did this is that WSDL 1.1 MIME attachments is more-or-less broken. For instance,
you cannot represent an array of attachments with WSDL 1.1. WSDL2Java WILL eventually digest
WSDL 1.1 WSDL in its limited usability, but Java2WSDL will never generate it.

Russell Butek

Please respond to 
To: <>
Subject: attachements and headers


I have the foolowing problem: I'm using WSDL2Java to generate
client code for a SOAP application. I would like to send attachments
and custom SOAP headers, but without touching the generated code.
Client code generation and usage is automatized so there is no way for me
to alter the generated code before using it. I know attechments can
be added to the Call object, but the Call objects are not available to
me any more, since they are created at every method call.
Is there any way currently that I can solve this problem ?

If there is no way, please read forward, and see what I figured out.
Looking at the Call source is that maybe I can
solve this by adding attachements and headers (or other info) to the
client stub using the generated API, as properties. These will
finally be put into the MessageContext by the Call object. This way
I might write a client-side handler that will extract those properties
and convert them into proper attachments, inserting them into the
Message object.

What do you think about this ? Will it work ?

Thanx in advance for your answers, Geza

View raw message