This is a great resource that will probably help you -

http://www.javaworld.com/javaworld/jw-09-2003/jw-0912-fop.html?

-Srinivas

-----Original Message-----
From: Greg Hess [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 11, 2003 2:36 PM
To: [EMAIL PROTECTED]
Subject: RE: Custom mapping's and DataHandlers?


Thanks Srinivas,

Funny, my current implementation is as you have outlined. 

I thought migrating to use DataHandler's and providing the attachment support via auto 
generated WSDL client code would be an improvement. I was concerned with the language 
dependant DataHandler Object but figured it was the "right way" and might simplify my 
client's use of the service, well my java clients anyway. But as noted it is a huge 
limitation to only support java clients.

Really my boss was up in arms after I sold him on SOAP and then told him I was going 
to have to introduce another level of complexity for the clients in order to support 
attachments. 

Will this mess be all sorted out with SOAP 1.2?

Kind Regards,

Greg 

> -----Original Message-----
> From: I-Sampige, Srinivas [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 11, 2003 4:56 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Custom mapping's and DataHandlers?
> 
> Greg,
>  To be honest, I don't know the answer to your question off the top of
my
> head, but this might be of help to you.....I have been doing a lot of 
> research on attachments of late. I have learnt that returning a 
> DataHandler is not a good way because of interoperability issues. The
best
> practice is not to pass complex language depentant objects across the
wire
> like for example - DataHandler in this case. If anybody finds my 
> understanding incorrect please feel free to correct me. So, I found an 
> alternative way of sending attachments back and forth -
> 
> Server side code-
>   public void ping(String msg)
>   {
>     System.out.println("In the new rebuilt ping 
> method.....................................");
>     Multipart multiPart = null;
>     try
>     {
>       FileInputStream fin = new
>
FileInputStream("C:\\workarea\\webservices\\bluesWebService\\test.pdf");
>       int avl = fin.available();
>       byte[] buf = new byte[avl];
>       ByteArrayInputStream bin = new  ByteArrayInputStream(buf);
>       bin.read();
>       ByteArrayDataSource bds = new 
> ByteArrayDataSource(buf,"application/pdf");
>       DataHandler dh = new DataHandler(bds);
>       fin.close();
> 
>       fin = new FileInputStream("C:\\workarea\\etrac\\Web
> Content\\images\\b_complete.gif");
>       avl = fin.available();
>       buf = new byte[avl];
>       bin = new ByteArrayInputStream(buf);
>       bin.read();
>       ByteArrayDataSource bds1 = new
ByteArrayDataSource(buf,"image/gif");
>       DataHandler dh1 = new DataHandler(bds1);
>       fin.close();
> 
> 
>       org.apache.axis.MessageContext messageContext = 
> org.apache.axis.MessageContext.getCurrentContext();
>       org.apache.axis.Message responseMessage = 
> messageContext.getResponseMessage();
> 
> 
>
//responseMessage.getAttachmentsImpl().setSendType(org.apache.axis.attac
hm
> ents.Attachments.SEND_TYPE_DIME);
> 
>       responseMessage.addAttachmentPart(new AttachmentPart(dh));
>       responseMessage.addAttachmentPart(new AttachmentPart(dh1));
> 
>       System.out.println("finished attaching the PDF to the
response");
>     }
>     catch (Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
> 
> Client side code -
>           String[] array = new String[1];
>           array[0] = "hello";
>           String returnValue = (String) call.invoke(array);
>           System.out.println("The return value is -> "+returnValue);
>           org.apache.axis.MessageContext messageContext = 
> call.getMessageContext();
>           org.apache.axis.Message returnedMessage = 
> messageContext.getResponseMessage();
>           System.out.println("Number of attachments is -> 
> "+returnedMessage.countAttachments());
>           returnedMessage.getAttachments();
> 
> 
> Hope this information helps you.
> 
> Thanks
> Srinivas
> 
> 
> -----Original Message-----
> From: Greg Hess [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 11, 2003 1:50 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Custom mapping's and DataHandlers?
> 
> 
> Many Thanks,
> 
> I have been studying the echoAttachments sample. Unfortunately I want
to
> adapt the use of attachments to work with my existing assets. I
currently
> have an operation that has a returnType="CustomBean" this "CustomBean"
has
> a property that accesses a byte[]. I would like to be able to maintain
the
> same service signature but alter my "CustomBean" to access a
DataHandler
> instead of the byte[].
> 
> Are attachments only supported as outlined in the echoAttachments
sample
> where the service defines a returnType="DataHandler" where the
DataHandler
> must be the root of the service response or request definition?
> 
> Would a custom Serializer/Deserializer support this functionality?
> 
> Thanks for your time,
> 
> Greg
> 
> 
> 
> > -----Original Message-----
> > From: I-Sampige, Srinivas [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 11, 2003 3:52 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Custom mapping's and DataHandlers?
> >
> > Here is how I returned a data handler from my web service method (a
> great
> > resource for you would be to look at the echoAttachments sampple
that
> > comes with Axis) -
> >
> > My WSSD -
> > <service name="NoAttachment" provider="java:RPC"> <operation 
> > name="ping" returnQName="returnqname"
> returnType="DataHandler">
> > <parameter name="op1" type="xsd:string"/>
> > </operation>
> > <parameter name="allowedMethods" value="*"/>
> > <parameter name="className" 
> > value="com.boeing.cuis.webservices.NoAttachment"/>
> > <typeMapping
> >
>
deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFac
> to
> > ry" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
> > qname="DataHandler"
> >
>
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory
> "
> > type="java:javax.activation.DataHandler"/>
> > </service>
> >
> > MY client side code -
> >         file://String endPoint = 
> > "http://localhost:7080/cuis/services/urn:NoAttachment";;
> >         String endPoint = 
> > "http://localhost:7080/cuis/services/NoAttachment";;
> >         String method = "sendMailWithAttachment";
> >         System.out.println("calling web service at - "+endPoint);
> >         try
> >         {
> >           Service  service = new Service();
> >           org.apache.axis.client.Call call  =
> > (org.apache.axis.client.Call) service.createCall();
> >           call.setTargetEndpointAddress(new java.net.URL(endPoint));
> >           //////// ping
> >           System.out.println("pinging the service..with an
> attachement");
> >           call.setOperationName(new QName("NoAttachment", "ping"));
> >           QName qnameAttachment = new QName("NoAttachment", 
> > "DataHandler");
> >           call.registerTypeMapping(DataHandler.class, file://Add 
> > serializer for attachment.
> >                                    qnameAttachment,
> >
> JAFDataHandlerSerializerFactory.class,
> >
> > JAFDataHandlerDeserializerFactory.class);
> >           call.addParameter( "op1", XMLType.XSD_STRING,
> ParameterMode.IN);
> >           call.setReturnType(qnameAttachment);
> >
> >
>
file://call.setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,Call.ATTACH
> ME
> > NT_ENCAPSULATION_FORMAT_DIME);
> >           String[] array = new String[1];
> >           array[0] = "hello";
> >           DataHandler returnValue = (DataHandler)
call.invoke(array);
> >           System.out.println("The return value is -> "+returnValue);
> >
> >
> > -----Original Message-----
> > From: Greg Hess [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 11, 2003 11:58 AM
> > To: [EMAIL PROTECTED]
> > Subject: Custom mapping's and DataHandlers?
> >
> >
> > Hi,
> >
> > One of the return classes of my service contains a large byte[]. I
> would
> > like to have the byte[] sent as an attachment. Following some
examples
> I
> > have implemented this by hand and sent the byte[] as an attachment
and
> > just set the byte[] to null before the response is sent. The client
> then
> > manually grabs the attachment.
> >
> > Preferably I would like this done automatically. I think I can
achieve
> > this is by:
> >
> > 1)       Have my service return a new wrapper class that converts
the
> > byte[] property to a DataHandler
> > 2)       Convert the classes <beanMapping> to a compete
<typeMapping>
> > defining the DataHandler property
> >
> > Unfortunately I am having great difficulty finding any resources
> outlining
> > this type of <typeMapping> and use of a DataHandler.
> >
> > Is this is even possible?
> >
> > Any help is greatly appreciated
> >
> > Greg Hess
> > Software Engineer
> > Wrapped Apps Corporation
> > 275 Michael Cowpland Dr.
> > Suite 201
> > Ottawa, Ontario
> > K2M 2G2
> > Tel: (613) 591 -7552
> > Fax: (613) 591-0523
> > 1 (877) 388-6742
> > www.wrappedapps.com
> >
> >
> >


Reply via email to