Version 2

    The Client Implementation

     

    We are using a DII client, note that, with the current JBossWS, you should be able to choose SAAJ or Proxy access.

    You may notice that only statndard classes are used. Thus, using any standard JAX-RPC stack implementation will be possible.

     

    ...
    import javax.activation.DataHandler;
    import javax.activation.FileDataSource;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.Call;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.ServiceFactory;
    ...
    

     

     

            String NS_PREFIX = "ns1";
            String NS_URI = "http://org.jboss.ws.example.attachment/MyService";
            QName APACHE_SOAP_DH = new QName("http://xml.apache.org/xml-soap","DataHandler"); 
            
            try{
                ServiceFactory factory = ServiceFactory.newInstance();
                Service service = factory.createService( new QName(NS_URI, "MyService") );
                Call call = service.createCall(new QName(NS_URI, "MyServicePort") );
                call.setTargetEndpointAddress(System.getProperty("jboss.url") + "/myservice/MyService");
                
                // send the text file
                call.setOperationName(new QName(NS_URI, "myService"));
                call.addParameter("mimepart", APACHE_SOAP_DH, ParameterMode.IN);
                call.setReturnType(APACHE_SOAP_DH);
                DataHandler dh = (DataHandler)call.invoke(new Object[]{ new DataHandler(new FileDataSource("resources/attachment_client2server.txt"))  });