axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Eirik.W...@bravida.no>
Subject RE: attachements and headers
Date Fri, 16 Aug 2002 13:41:34 GMT
Hi!

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

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) { this.name = name; }

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

I run this through Java2WSDL and get:

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

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: butek@us.ibm.com [mailto:butek@us.ibm.com]
Sent: 16. august 2002 14:55
To: axis-user@xml.apache.org
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="http://xml.apache.org/xml-soap" ...

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

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

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
butek@us.ibm.com


Please respond to axis-user@xml.apache.org 
To: <axis-user@xml.apache.org>
cc: 
Subject: attachements and headers



Hi,

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

Mime
View raw message