I'm attempting to send a tiff file from servlet to client by wrapping it in a 
datahandler and returning the datahandler via RPC.  I'm developing in Eclipse 
with JBoss 4.0.2.  At the server, the datahandler is created correctly, but on 
the client side, the object that is returned is apparently an AttachmentPart 
rather than a datahandler, and it's also very much null.  In fact the 
datahandler contained within it is useless.  After multiple tries with multiple 
sources, I followed JBossWSAttachStepByStep to a T.

Here's the server code which works fine:

  | try{
  |     File theFile = new File(testTiff);
  |     DataSource ds = new ByteArrayDataSource(theFile, "image/tiff");
  |     DataHandler dh = new DataHandler(ds);
  |     return dh;
  | }
  | catch(Exception ex) { ... }
  | 

Here's the client code:

(To avoid confusion, if I just say 
DataHandler ret = call.invoke(...); 
or
DataHandler ret = (DataHandler) call.invoke(...);
which is what I was doing originally, it still doesn't work.  
I've only just pasted my most recent code.)


  | try {
  |     DataHandler dh = null;
  |             String endpoint = 
"http://dd-hanson:8080/serviceName/Controller?wsdl";;
  |         URL myURL = new URL(endpoint);
  |         QName myQ = new QName(NAMESPACE_URI, "ControllerService");
  |         ServiceFactory factory = 
(ServiceFactory)ServiceFactory.newInstance();
  |         Service  service = (Service)factory.createService(myURL, myQ);
  |         Call call = (Call)service.createCall(new QName(NAMESPACE_URI, 
SERVICE_PORT) );
  |         call.setTargetEndpointAddress(endpoint);
  |         call.setOperationName(new QName("http://web.imaging/wsdl";, 
"getImage"));
  | 
  |         Object ret = call.invoke(new Object[]{imageID});
  | 
  |         System.out.println("ret is type: " + ret.getClass());  // This is 
how I know 'ret' is an AttachmentPart
  |         dh = 
(DataHandler)((org.apache.axis.attachments.AttachmentPart)ret).getDataHandler();
  |     return dh;      // By this point dh is just about as useless as null.
  | }
  |         catch (Exception ex) { ... }
  | 

Here's my WSDL:

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <definitions name="ControllerService" 
  |     targetNamespace="http://web.imaging/wsdl"; 
  |     xmlns:tns="http://web.imaging/wsdl"; 
  |     xmlns="http://schemas.xmlsoap.org/wsdl/"; 
  |     xmlns:ns2="http://java.sun.com/jax-rpc-ri/internal"; 
  |     xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
  |     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
  |     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/";>
  |   
  |   <types />
  | 
  |   <message name="FrontControllerInterface_getImage">
  |     <part name="String_1" type="xsd:string"/></message>
  |   <message name="FrontControllerInterface_getImageResponse">
  |     <part name="result" type="xsd:hexBinary"/></message>
  |   <!-- GetImageResponse used to be type="ns2:datahandler" -->
  | 
  |   <portType name="FrontControllerInterface">
  |  
  |     <operation name="getImage" parameterOrder="String_1">
  |       <input message="tns:FrontControllerInterface_getImage"/>
  |       <output 
message="tns:FrontControllerInterface_getImageResponse"></output>     
  |     </operation>
  |   </portType>
  | 
  |   <binding name="FrontControllerInterfaceBinding" 
type="tns:FrontControllerInterface">
  |     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; 
style="rpc"/>
  |  
  |     <operation name="getImage">
  |       <soap:operation soapAction=""/>
  |       <input>
  |         <soap:body use="literal" 
namespace="http://web.imaging/wsdl"/></input>
  |       <output>
  |         <soap:body use="literal" namespace="http://web.imaging/wsdl"/>
  |       <mime:multipartRelated>
  |         <mime:part>
  |           <soap:body use="literal" namespace="http://web.imaging/wsdl"/>
  |         </mime:part>
  |         <mime:part>
  |           <mime:content part="result" type="image/tiff" />
  |         </mime:part>
  |       </mime:multipartRelated>
  |       </output>
  |     </operation>
  |   </binding>
  |   <service name="ControllerService">
  |     <port name="FrontControllerInterfacePort" 
binding="tns:FrontControllerInterfaceBinding">
  |       <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service>
  | </definitions>
  | 

Here's my webservices.xml:

  | <webservices xmlns="http://java.sun.com/xml/ns/j2ee";
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  |     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  |     http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd";
  |     version="1.1">
  |     <webservice-description>
  |             
<webservice-description-name>ControllerService</webservice-description-name>
  |             <wsdl-file>WEB-INF/wsdl/ControllerService.wsdl</wsdl-file>
  |             <jaxrpc-mapping-file>WEB-INF/mapping.xml</jaxrpc-mapping-file>
  |             <port-component>
  |                     <port-component-name>PortComponent</port-component-name>
  |                     <wsdl-port>FrontControllerInterfacePort</wsdl-port>
  |                     <service-endpoint-interface>
  |                             imaging.web.FrontControllerInterface
  |                     </service-endpoint-interface>
  |                     <service-impl-bean>
  |                             <servlet-link>Controller</servlet-link>
  |                     </service-impl-bean>
  |             </port-component>
  |     </webservice-description>
  | </webservices>
  | 

Here's my mapping file:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee"; 
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
  |     version="1.1" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  |     http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd";>
  | <package-mapping>
  |  <package-type>imaging.web</package-type>
  |  <namespaceURI>http://web.imaging/wsdl</namespaceURI>
  | </package-mapping>
  | <service-interface-mapping>
  |  <service-interface>imaging.web.ControllerService</service-interface>
  |  <wsdl-service-name 
xmlns:serviceNS="http://web.imaging/wsdl";>serviceNS:ControllerService</wsdl-service-name>
  |  <port-mapping>
  |   <port-name>FrontControllerInterfacePort</port-name>
  |   <java-port-name>FrontControllerInterfacePort</java-port-name>
  |  </port-mapping>
  | </service-interface-mapping>
  | <service-endpoint-interface-mapping>
  |  
<service-endpoint-interface>imaging.web.FrontControllerInterface</service-endpoint-interface>
  |  <wsdl-port-type 
xmlns:portTypeNS="http://web.imaging/wsdl";>portTypeNS:FrontControllerInterface</wsdl-port-type>
  |  <wsdl-binding 
xmlns:bindingNS="http://web.imaging/wsdl";>bindingNS:FrontControllerInterfaceBinding</wsdl-binding>
  |  <service-endpoint-method-mapping>
  |   <java-method-name>getImage</java-method-name>
  |   <wsdl-operation>getImage</wsdl-operation>
  |   <method-param-parts-mapping>
  |    <param-position>0</param-position>
  |    <param-type>java.lang.String</param-type>
  |    <wsdl-message-mapping>
  |     <wsdl-message 
xmlns:wsdlMsgNS="http://web.imaging/wsdl";>wsdlMsgNS:FrontControllerInterface_getImage</wsdl-message>
  |     <wsdl-message-part-name>String_1</wsdl-message-part-name>
  |     <parameter-mode>IN</parameter-mode>
  |    </wsdl-message-mapping>
  |   </method-param-parts-mapping>
  |   <wsdl-return-value-mapping>
  |    <method-return-value>javax.activation.DataHandler</method-return-value>
  |    <wsdl-message 
xmlns:wsdlMsgNS="http://web.imaging/wsdl";>wsdlMsgNS:FrontControllerInterface_getImageResponse</wsdl-message>
  |    <wsdl-message-part-name>result</wsdl-message-part-name>
  |   </wsdl-return-value-mapping>
  |  </service-endpoint-method-mapping>
  | </service-endpoint-interface-mapping>
  | </java-wsdl-mapping>
  | 

Someone please help, I've wasted a week of company time trying to make this 
work!  Thanks so much.

Steve

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3902135#3902135

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3902135


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to