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.JAFDataHandlerDeserializerFactory" 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.ATTACHMENT_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
