You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "I-Sampige, Srinivas" <sr...@Boeing.com> on 2003/10/31 03:52:26 UTC
Returning attachments from a web service..
I was able to successfully return a "DataHandler" from my web service method and process it on the client side.
This is what I used in the WSDD -
-------------------------------
<typeMapping deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns2:DataHandler"
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
type="java:javax.activation.DataHandler" xmlns:ns2="urn:EchoAttachmentsService"/>
---------------
This is what I did on the client side -
----------------
QName qnameAttachment = new QName("urn:Email", "DataHandler");
call.registerTypeMapping(DataHandler.class, //Add serializer for attachment.
qnameAttachment,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);
call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(qnameAttachment);
String[] array = new String[1];
array[0] = "hello";
DataHandler returnedDh = (DataHandler) call.invoke(array);
-----------------
But, now, I want to return multiple DataHandlers from my method by putting them in a javax.mail.internet.Multipart. This is what I am attempting -
public Multipart getAttachments()
{
MultiPart multiPart = new MimeMultipart();
MimeBodyPart mbp1 = new MimeBodyPart();
String message = "SUCCESS";
mbp1.setText(message,"us-ascii");
MimeBodyPart mbp2 = new MimeBodyPart();
mbp1.setDataHandler(dh);
multiPart.addBodyPart(mbp1);
multiPart.addBodyPart(mbp2);
return multiPart
}
QUESTIONS:
1) I am not able to figure out what the corresponding serializer/deserializer would be?
2) Is this the best way of having my web service return an attachement? I would like to return some message like "Here is the product you slected" along with a PDF product manual, a gif image of the product and perhaps a video clip.
Thanks
Srinivas