Apache | WS |
Handler TutorialContentsIntroduction to Handlers
Handlers are pluggable components in Axis C++. Handlers are pieces of code that you write to intercept the message either on the client or service side. We have included a set of sample handlers for your reference. Handler samplesWe have included the following sample Handlers for your reference.
echoStringHeaderHandler (A server side handler sample)Building the echoStringHeaderHandlerLinuxThe build files are available at: <Axis install directory>/samples/server/echoStringHeaderHandler Change your current directory to this directory and then execute the following...
The handler libeshhandler.so file will be created at <Axis install directory>/lib directory WindowsThe VC dsw file (ServerHandlers.dsw) is available at <Axis Install directory>/vc/samples/server/ServerHandlers.dsw. Open this file and build the project echoStringHeaderHandler. Once the build is successful you will find the DLL ( echoStringHeaderHandler.dll) at: <Axis install directory>/bin Configuring the echoStringHeader HandlerEdit the server.wsdd file (as created when you configured your server ) to include the handler for a particular service. <service name="Calculator" provider="CPP:RPC" description="Simple Calculator Axis C++ Service"> <requestFlow name="CalculatorHandlers"> <handler name="ESHHandler" type="<Axis installation directory>/handlers/custom/echoStringHeaderHandler/libeshhandler.so"> </handler> </requestFlow> <responseFlow name="CalculatorHandlers"> <handler name="ESHHandler" type="<Axis installation directory>/handlers/custom/echoStringHeaderHandler/libeshhandler.so"> </handler> </responseFlow> <parameter name="allowedMethods" value="add sub mul div"/> <parameter name="className" value="<Axis installation directory>/webservices/libcalculator.so" /> </service>Note: Running the echoStringHeader HandlerSince this Handler is configured to the Calculator web service in the above step, this Handler will be executed when a client sends a SOAP request to the Calculator web service. Use the calculator client you created earlier. testHandler (A client side handler sample)Building the testHandlerThe build files are available at <Axis installation directory>/samples/client/testHandler. Change your current directory to this directory and then you can execute the following. Linux
The handler so file will be created at <Axis installation directory>/lib/ WindowsThe VC dsw file (ClientHandlers.dsw) is available at: <Axis Installation directory>/vc/samples/client/ClientHandlers.dsw Open this file and build the project TestHandler. Once the build is successful you will find the DLL (testHandler.dll) at: <Axis Installation directory>/bin If you see this DLL at the above location you are done with the first step. Configuring the testHandlerNow edit the <Axis installation directory>/etc/client.wsdd to include the handler for a particular service. In this example we will continue to use the Calculator service. The sample wsdd file outlined below shows a linux directory system - for other operating systems please use the correct path symbols. <service name="Calculator" provider="CPP:RPC" description="Calculator web service"> <requestFlow name="CalculatorHandlers"> <handler name="TestHandler" type="<Axis Installation directory>/lib/libtest_client_handler.so"> </handler> </requestFlow> </service> Now you are almost ready to run your client side handler. Running the testHandlerSince this Handler is configured to the Calculator web service in the above step, this Handler will be executed when you run the calculator web service client.. The Handler API's
Now you have seen some sample Handlers you can explore more on Handlers. The following sections should help you understand that API's available to you in your handler code. // ----- In order to get access to a incoming HeaderBlock the handler writer can use the following code block. In order to manipulate the above accessed HeaderBlock the handler writer can use the following code block. .....
Notes:
The BasicNode API is similar (not exactly the same, but ..) to the DOM and is written as a tree traversing API. |