Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages | Examples

HandlerBase Class Reference

interface for the Handlers. This is the base class for: -Handler -WrapperClassHandler In the Axis Architecture there are different types of Handlers : -NORMAL_HANDLER : A Handler which is used to process SOAP Headers. -WEBSERVICE_HANDLER : A web service is also considered as a Handler. -CHAIN_HANDLER : Handler Chains are also derived from Handler. Each of these handlers will inherit from this HandlerBase which serves as the base point for all the different types of Handlers. More...

#include <BasicHandler.hpp>

Inheritance diagram for HandlerBase:

Handler WrapperClassHandler List of all members.

Public Member Functions

 HandlerBase ()
virtual ~HandlerBase ()
virtual int AXISCALL invoke (void *pMsg)=0
virtual void AXISCALL onFault (void *mMsg)=0
virtual int AXISCALL init ()=0
virtual int AXISCALL fini ()=0
virtual int AXISCALL getType ()=0

Detailed Description

interface for the Handlers. This is the base class for: -Handler -WrapperClassHandler In the Axis Architecture there are different types of Handlers : -NORMAL_HANDLER : A Handler which is used to process SOAP Headers. -WEBSERVICE_HANDLER : A web service is also considered as a Handler. -CHAIN_HANDLER : Handler Chains are also derived from Handler. Each of these handlers will inherit from this HandlerBase which serves as the base point for all the different types of Handlers.

Author:
Susantha Kumara (skumara@virtusa.com)

Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)


Constructor & Destructor Documentation

HandlerBase::HandlerBase  )  [inline]
 

Constructor.

virtual HandlerBase::~HandlerBase  )  [inline, virtual]
 

Destructor.


Member Function Documentation

virtual int AXISCALL HandlerBase::fini  )  [pure virtual]
 

The finalization tasks which needs to be performed within a Handler has to be written here. This method will be automatically called by the Axis Engine when it unloads a handler.

Returns:
AXIS_SUCCESS or AXIS_FAIL to indicate success or fail.

virtual int AXISCALL HandlerBase::getType  )  [pure virtual]
 

Gets and returns the type of the handler. The return value could be :

  • NORMAL_HANDLER
  • WEBSERVICE_HANDLER
  • CHAIN_HANDLER

Returns:
This returns the following depending on the actual Handler type:
  • NORMAL_HANDLER : In case of a normal Handler which is used to process SOAP Headers.
  • WEBSERVICE_HANDLER : In case of a Web Service.
  • CHAIN_HANDLER : In case of a HandlerChain

Implemented in Handler, and WrapperClassHandler.

virtual int AXISCALL HandlerBase::init  )  [pure virtual]
 

The initialization tasks which needs to be performed within a Handler has to be written here. This method will be automatically called by the Axis Engine when it loads a handler.

Returns:
AXIS_SUCCESS or AXIS_FAIL to indicate success or fail.

virtual int AXISCALL HandlerBase::invoke void *  pMsg  )  [pure virtual]
 

The invoke method is automatically called by the Axis Engine when it needs to execute a Handler. The main task of the handler which a Handler writer expects the Handler to be performed needs to be written within the invoke method of the Handler.

A example code segment within a invoke method which is written to process a SOAP Header is as following:

 int ESHHandler::invoke(void *pvIMsg)
 {
 IMessageData *pIMsg = (IMessageData*) pvIMsg;
    AxisChar* pachTemp;
    if(pIMsg->isPastPivot()) {
        //this is a response

        IHandlerSoapSerializer* pISZ;
        pIMsg->getSoapSerializer(&pISZ);

        IHeaderBlock* pIHeaderBlock= pISZ->createHeaderBlock();

        pIHeaderBlock->setLocalName("echoMeStringResponse");
        pIHeaderBlock->setURI("http://soapinterop.org/echoheader/");

        pachTemp = "EchoStringHeaderHandlerPr1.id";

        const AxisChar* pachHeaderVal = pIMsg->getProperty(pachTemp);
        printf("in the ESHHandler::Invoke : %s\n",pachHeaderVal);

        BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
        pBasicNode->setValue(pachHeaderVal);

        pIHeaderBlock->addChild(pBasicNode);

 } else {
        //this is a request

        IHandlerSoapDeSerializer* pIHandlerSoapDeSerializer;
        pIMsg->getSoapDeSerializer(&pIHandlerSoapDeSerializer);

        IHeaderBlock* pIHeaderBlock= pIHandlerSoapDeSerializer->getHeaderBlock("echoMeString", "http://soapinterop.org/echoheader/");

        if (pIHeaderBlock != NULL) {

            const BasicNode* pBasicNode= pIHeaderBlock->getFirstChild();

            const AxisChar* pachHeaderValue;

            if (pBasicNode != NULL)
            {
                if((pBasicNode->getNodeType()) == CHARACTER_NODE) {
                    pachHeaderValue= pBasicNode->getValue();
                } else {
                    pachHeaderValue = "This was not the expected value Ros";
                }
            } else
            {
                pachHeaderValue = "pBascNode is NULL";
            }

            AxisChar* pachTmpValue = (AxisChar*) malloc(strlen(pachHeaderValue) + 4);
            strcpy(pachTmpValue, pachHeaderValue);

            pachTemp = "EchoStringHeaderHandlerPr1.id";
            pIMsg->setProperty(pachTemp, pachTmpValue);

            free(pachTmpValue);

        } else {
            //do some thing
        }

    }

    return AXIS_SUCCESS;
    }
 

In case of a Web Service Handler the invoke method should do what is required by a web service invoke method, which is different from the above shown example.

Parameters:
pMsg The MessageData object pointer. This MessageData object is passed to every handler when serving to a client request. The handler writer can get access to objects such as:
  • IHandlerSoapDeSerializer
  • IHandlerSoapSerializer
  • The properties/data/info which are set by other handlers
  • The properties/data/info which is set by the Client Stub in case the Handler is a Client side Handler. etc.
Returns:
AXIS_SUCCESS or AXIS_FAIL to indicate success or fail.

virtual void AXISCALL HandlerBase::onFault void *  mMsg  )  [pure virtual]
 

Called when ever a fault is occured within the handler. The tasks which needs to be persormed when ever an error occurs within a Handler has to be written within this method.

Parameters:
mMsg The MessageData object pointer. This MessageData object is passed to every handler when serving to a client request. The handler writer can get access to objects such as:
Returns:
AXIS_SUCCESS or AXIS_FAIL to indicate success or fail.


The documentation for this class was generated from the following file:
Generated on Sat Apr 9 15:11:57 2005 for AxisC++ by doxygen 1.3.8