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 Yuvraj Waswani <Yu...@tavant.com> on 2003/09/19 07:19:17 UTC
How to send java-serialized in-memory objects as attachments
-----Original Message-----
From: Yuvraj Waswani [mailto:Yuvraj.Waswani@tavant.com]
Sent: Thursday, September 18, 2003 5:13 PM
To: axis-user@ws.apache.org (E-mail); axis-user@xml.apache.org (E-mail)
Subject: Sending Jav-Serialized Objects as Attachments
Hi,
Need some help over sending attachments :--
1. Due to performance reasons (my bean objects being immensely bulky), I
wish to send my object as an attachment after Java-serializing it through
ObjectOutputStream. How do I do it? How can I use ObjectOutputStream to
first serialize my object and then send it across as soap attachment?
2. Does axis support sending only "DataHandler" types as attachments?? I use
the below code to encapsulate my object inside DataHandler and then send it
across as soap attachment, but I get the following exception :-- (Any
clues?)
"javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
application/x-java-serialized-object "
AnyJavaObject obj = new AnyJavaObject();
obj.modifyVector();
obj.vector.add(new StringBuffer("This is the stringBuffer object
content"));
DataHandler dhSource = new
DataHandler(obj,"application/x-java-serialized-object");
QName qnameAttachment = new QName("myAttachmentNamespace",
"MyObjectAttachment");
String endpoint =
"http://localhost:7003/axisWebApp/services/AttachmentWebService";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName("receiveJavaObjectAttachment");
call.setOperationName(new
javax.xml.namespace.QName("AttachmentWebServiceNameSpace",
"receiveJavaObjectAttachment"));
call.registerTypeMapping(dhSource.getClass(),
qnameAttachment,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);
call.addParameter("source", qnameAttachment, ParameterMode.IN);
call.setReturnType(new QName("erf","ef"),java.lang.String.class);
call.setProperty(call.ATTACHMENT_ENCAPSULATION_FORMAT,
call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
String mess = (String)call.invoke(new Object[]{dhSource});