I have written a simple CXF WebService using MTOM as a proof of concept
for future work.
I have successfully written a CXF WS client, however I am now writing an
Axis2 WS client and am having some trouble and was hoping someone could
give some pointers. I am using Java 1.5, Axis2 1.3, and CXF 2.0.2
 
I am using TCPMON to watch the SOAP requests and responses 
Axis2 --> TCPMON --> CXF Service
 
and here is what seems to be happening...
The request and response are successfully made (I see them both in
TCPMON and both are using MIME/MTOM).
The Axis2 client (running as a Junit test in eclipse) hangs and CPU
spikes to 100%
The State in TCPMON is Req and does not get set to Done
 
Let me know if any other information would be helpful
 
Here is my Axis2 client
 
protected OMElement createPayload_SayHello(String nameText) throws
IOException{

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace namespace =
factory.createOMNamespace("http://hello.bah.com/";, "ns1");
        OMElement root = factory.createOMElement("sayHello", namespace);
         
        OMElement arg0 = factory.createOMElement("arg0", null);
        root.addChild(arg0);
         
        OMElement name = factory.createOMElement("name", null);
        name.setText(nameText);
        arg0.addChild(name);
         
        InputStream is =
IOHelper.getStreamFromClassPathFile("com/bah/hello/PensiveDuke.gif");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOHelper.inputToOutput(is, baos);
        DataSource ds = new
ByteArrayDataSource(baos.toByteArray(),"content/type");
        DataHandler dh = new DataHandler(ds);
        OMText binaryData = factory.createOMText(dh, true);
         
        OMElement bd = factory.createOMElement("binaryData", null);
        bd.addChild(binaryData);
        arg0.addChild(bd);
        return root;

}
 
public void test_WS_sayHello(){

        try {
        ServiceClient sc = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(SERVICE_ADDRESS));
        opts.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
        sc.setOptions(opts);
         
        OMElement requestElement = this.createPayload_SayHello("Axis2");
        OMElement responseElement = sc.sendReceive(requestElement);
        System.out.println("Response: " + responseElement);
         
        assertNotNull(responseElement);
        assertEquals("sayHelloResponse",responseElement.getLocalName());
        OMElement returnElement = responseElement.getFirstElement();
        assertNotNull(returnElement);
        assertEquals("return",returnElement.getLocalName());
         
        String responseXml = returnElement.getText();
        assertNotNull(responseXml);
        assertEquals("Hello Axis2",responseXml);
        } 
        catch (AxisFault e) {
        System.out.println(e.getMessage());
        fail("Unexpected AxisFault");
        }
        catch (IOException e) {
        System.out.println(e.getMessage());
        fail("Unexpected IOException");
        }
        }

}
 
TIA
 
Mike Barlotta
Associate
Booz | Allen | Hamilton
 

Reply via email to