axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Hess" <gh...@wrappedapps.com>
Subject RE: Custom mapping's and DataHandlers?
Date Tue, 11 Nov 2003 21:49:41 GMT
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:srinivas.sampige@boeing.com]
> Sent: Tuesday, November 11, 2003 3:52 PM
> To: axis-user@ws.apache.org
> 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:ghess@wrappedapps.com]
> Sent: Tuesday, November 11, 2003 11:58 AM
> To: axis-user@ws.apache.org
> 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
> 
> 
> 


Mime
View raw message