login button

How to Find the Service and the Operation Associated with a SOAP Message

Story :

Level : Realm : Project :

Some times we might want to perform various actions, depending on the current service and operation. This knowledge base outlines how one can find the service and the operation associated with the message being processed.

Applies To

1. Apache Axis2/Java 1.3 or later

2. JDK 1.4 or later

 

If you are authoring a handler, to be deployed within Axis2, you might want to know what the related service and operation is for the current message being processed. This is very easy to find, when you are within Axis2.

Axis2 uses an execution chain, consisting of set of handlers to process the message before handing over the message to the service implementation class. This execution chain is divided in to parts, called phases, to easily point to various locations within this execution pipe. When you deploy a handler in to Axis2, it will be put at a certain location, in the execution pipe. If you are not hacking Axis2 kernel, once deployed, your handler will be placed after the dispatching phase.

Dispatching phase is responsible for finding for the service and the operation the current message being processed, relates to. By the time Axis2 finishes with dispatching phase, if it can not find both the service and operation, it will send out an error to the user, as it can not route the message to a deployed service implementation. (For more information on how Axis2 dispathing work, please refer "How Apache Axis2 Finds the Operation and Service a Message is Destined To")

So by the time, your handler gets executed, Axis2 must have found the service and operation. Use following two methods to get information about the service and operation related to the message. You can then log those information or perform actions depending on those information.

AxisService service = messageContext.getAxisService();
String serviceName = service.getName(); // gives out the name of the service
Iterator allOperations = service.getOperations(); // returns all the operations of this service

AxisOperation operation = messageContext.getAxisOperation();
String operationName = operation.getName(); // gives out the name of the operation
String mep = operation().getMessageExchangePattern(); // gives the message exchange pattern of this operation

Author : Eran Chinthaka, Member-Apache Software Foundation. eran(dot)chinthakaXgmail.com, where X=@

0
No votes yet
Tags :