They complement each other very good. SOAP adds portability and extensibility since it is not bound to any programming language or OS and it is based on XML Schema. XML Schema allows you to extend the contant and SOAP has the notion of a HEADER. WLNG is extensible with new protocols and interfaces still utilizing the same policy control. In my previous post you could read about how to extend WLNG using the Policy features. In this post I will discuss on how to extend using SOAP Message Handlers.
But before I start to expain a little about how to actually do it, I would like to discuss what you can do with it? Here's a list:
- Validates the IP address of the caller
- Replaces some data in the message, for example masking the MSISDN
- Extracting transaction id or other data from the header and associates it with the call. This data can later be retrieved in a policy for example
So, first the basics. WLNG uses Axis for it's WebServices. With Axis comes a couple of Ant tasks that are used to generate the stubs and skeletons Java files from a WSDL file. It also generates the deployment file server-config.wsdd. In here lies the magic when it comes to extending WebServices with SOAP Message Handlers.
You can have a SOAP MEssage Handler on both the request and the response (that is sent back to the client). It can be on both the client and the server side. What I'm discussing here applies to all cases.
The other thing you need to know and do is to create the class(es) that implement the new Message Handler and doing whatever you want it to do. You should normally implement the interface javax.xml.rpc.handler.Handler (http://ws.apache.org/axis/java/apiDocs/javax/xml/rpc/handler/Handler.html).
When you have done that compile and jar it.
No the time has come for some fun. First you have to update the server-config.wsdd file with your new classes that implements the Handler interface. You can read more about how to do it here: http://ws.apache.org/axis/java/reference.html#DeploymentWSDDReference.
It's not very easy to understand so here's an example:
Handler definition:
<handler name="GenericHandler" type="java:org.apache.axis.handlers.JAXRPCHandler">
<parameter name="scope" value="request"/>
<parameter name="className" value="com.bea.wlcp.test.soap.GenericSoapHandler"/>
</handler>Handler Chain:
<requestFlow>
<chain name="TestChain">
<handler type="GenericHandler"/>
<handler type="AuthenticationHandler"/>
<handler type="TransactionHandler"/>
</chain>
</requestFlow>
The Handler Chain is defined per service after all the operations declarations.
Finally you create an Ant target in you build file. The Ant target updates the war-file making up the WebSerice (for example parlayx.war) with the updated server-config.wsdd and the jar-file containing the actual aimplementation. Remember to place the jar-file in the WEB-INF/lib directory.
Related to this topic is how to associate the data with the current request. That will be another topic on this blog. Stay tuned :-)

Inga kommentarer:
Skicka en kommentar