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 :--

"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});

Reply via email to