You need to create an implementation of the
javax.xml.rpc.handler.GenericHandler class, and intercept the web-services call
before it makes it to your SEI.
So, create a handler class (separate from your SEI interface and impl). Makes
sure this handler class extends GenericHandler (see above for correct package).
You'll need to override the function "public QName[] getHeaders()" (because
it's abstract in GenericHandler) so that it returns the QNames of the services
you want "handled".
Mine looks like this (this is just the QName of each endpoint):
| public class ExampleGenericHandler extends GenericHandler
| {
|
| @Override
| public QName[] getHeaders()
| {
| String NAMESPACE = "http://com.example";
| QName SERVICE_NAME = new QName(NAMESPACE, "MySEI_JSEService");
|
| QName[] qNames = {SERVICE_NAME};
| return qNames;
| }
| }
|
Next, in your webservices.xml descriptor that is deployed with your webservice,
you'll want to include the handler definition inside of the port-component,
like so:
|
| <webservices
| ...
|
| <webservice-description>
| <webservice-description-name>...</webservice-description-name>
| <wsdl-file>..._JSEService.wsdl</wsdl-file>
| ...
| <port-component>
| <port-component-name>PortComponent</port-component-name>
| <wsdl-port>ExamplePort</wsdl-port>
|
<service-endpoint-interface>com.example.exampleInterface</service-endpoint-interface>
| <service-impl-bean>
| <servlet-link>Serlvet</servlet-link>
| </service-impl-bean>
| <handler>
| <handler-name>ExampleHanlder</handler-name>
| <handler-class>com.example.ExampleHandler</handler-class>
| </handler>
| </port-component>
| </webservice-description>
| </webservices>
|
If you already have a functional web-services SEI working, then you should
already have everything in place to implement the above (including a
webservices.xml file).
Finally, in your GenericHandler class, you can do something like this:
|
| /* (non-Javadoc)
| * @see
javax.xml.rpc.handler.GenericHandler#handleRequest(javax.xml.rpc.handler.MessageContext)
| */
| @Override
| public boolean handleRequest(MessageContext context)
| {
| //Output the IP address of the caller.
| String ip = (String) context.getProperty("remoteaddr");
| log.error("Caller IP: " + ip);
|
| return super.handleRequest(context);
| }
|
For more info about GenericHandlers, see:
http://labs.jboss.com/portal/jbossws/user-guide/en/html/headers-handlers.html#handlers
Also, this post was helpful if you want to try to determine what all the
properties can be found in MessageContext:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=62299
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3935845#3935845
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3935845
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user