ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Web Services Messaging with Apache Axis2: Concepts and Techniques
Pages: 1, 2, 3, 4

  1. In-Out asynchronous, HTTP using HTTP as two-way transports
    
    //this is the payload goes on the body of SOAP message 
    OMElement payload = .... 
    Call call = new Call();
    call.setTo(
            new EndpointReference(AddressingConstants.WSA_TO,
                    "HTTP://...));
    call.setTransportInfo(Constants.TRANSPORT_HTTP,
                  Constants.TRANSPORT_HTTP, false);
    
    Callback callback = new Callback() {
        public void onComplete(AsyncResult result) {
            //what user can do to result
        }
        public void reportError(Exception e) {
           //on error
        }
    };
    call.invokeNonBlocking(operationName.getLocalPart(),
           payload, callback);
    
    

    As before, the SOAP messages travel through the same HTTP connection and the invocation does not require addressing. The client API will not block and the callback will be executed once the response message arrives.

  2. In-Out, asynchronous HTTP as one-way transport
    
    OMElement payload = .... 
    Call call = new Call();
    call.setTo(
            new EndpointReference(AddressingConstants.WSA_TO,
                    "HTTP://...));
    call.setTransportInfo(Constants.TRANSPORT_HTTP,
        Constants.TRANSPORT_HTTP, true);
    Callback callback = new Callback() {
            public void onComplete(AsyncResult result) {
            ....
            }
    
            public void reportError(Exception e) {
            ...
            }
    };
    call.engageModule(new Qname("addressing"));
    call.invokeNonBlocking(operationName.getLocalPart(), method, callback);
    
    

    In this case, the SOAP messages travel through two HTTP connections, addressing is mandatory, and the presence of the ReplyTo header instructs the server to send the response in a separate channel. The client does not block, and when the response message arrives, the callback is invoked.

  3. In-Out, synchronous HTTP as one-way transport
    
    OMElement payload = .... 
    Call call = new Call();
    call.setTo(
    new EndpointReference(AddressingConstants.WSA_TO,
            "HTTP://...));
    call.setTransportInfo(Constants.TRANSPORT_HTTP,
        Constants.TRANSPORT_HTTP, true);
    OMElement result =
            (OMElement) call.invokeBlocking(
               operationName.getLocalPart(), payload);
    
    

    This uses a "In-Out, asynchronous HTTP as one-way transport" type of invocation under the curtain, but the invocation blocks until the result arrives in the second connection, and execution returns with the result.

Summary

In summary, the behavior of web service messaging is based on three parameters: the message exchange pattern, the synchronous/asynchronous behavior of the client, and the behavior of the transport. Axis2 is built on a core that is not bound to any type of MEP, yet provides client API support for the most widely used MEPs: one-way and request-response. The article explains the concepts behind the Axis2 messaging support and how the client API is used.



Resources

Srinath Perera is a principal architect for Apache Axis2.

Ajith Ranabahu is a committer for the Apache Axis2 project and has been working on web-service-based projects for the past three years.


Return to ONJava.com.