Title: RE: Adding a custom handler

I have the following working

=========================================================================

  QName portName = stub.getPortName () ;

  Service service = stub._getService () ; // Axis 1.2 RC2

  HandlerRegistry handlerRegistry = service.getHandlerRegistry () ;

  List handlerChain = handlerRegistry.getHandlerChain ( portName ) ;

  MyHandlerInfo handlerInfo = new MyHandlerInfo () ;

  handlerInfo.setHandlerClass ( MyHandler.class ) ;

  handlerChain.add ( handlerInfo ) ;

  handlerRegistry.setHandlerChain ( portName, handlerChain ) ;

=========================================================================

  public class MyHandler implements Handler
  {
    public void init ( HandlerInfo handlerInfo ) throws JAXRPCException
    {
        if ( handlerInfo instanceof MyHandlerInfo )
        {

        }
    }

    public void destroy () throws JAXRPCException
    {
    }

    public QName[] getHeaders ()
    {
        return new QName[0] ;
    }

    public boolean handleFault ( MessageContext messageContext ) throws JAXRPCException
    {
        return true ; // return true to continue processing
    }

    public boolean handleRequest ( MessageContext messageContext ) throws JAXRPCException
    {
        SOAPMessage message = ((SOAPMessageContext)messageContext).getMessage () ;

        return true ; // return true to continue processing
    }

    public boolean handleResponse ( MessageContext messageContext ) throws JAXRPCException
    {
        return true ; // return true to continue processing
    }

=========================================================================


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 1 March 2005 3:26 AM
To: [email protected]
Subject: Adding a custom handler


Hi.

I'm writing a client side Axis application, in which I need to create my
own custom handler.

I'm using WSDL2Java to generate my code stubs, and I was hoping that I
could add a handler as follows:

                                HandlerRegistry registry  =
service.getHandlerRegistry();
                                QName portName = s.getPortName();
                                List handlerChain =
registry.getHandlerChain(portName);
                                HandlerInfo handlerInfo = new
HandlerInfo();
 handlerInfo.setHandlerClass(com.foo.MyHandler);
                                handlerChain.add(handlerInfo);
                                registry.setHandlerChain(portName,
handlerChain);


But when I run the client application, it would seem this handler is not
called as both the handleRequest and handleResponse methods produce no
output (I've added in System.out's to them to see if it works)

Does anyone have any ideas of what I may be missing?

Thanks.
James


This email is intended solely for the use of the named addressee(s). Any
unauthorised disclosure, copying or distribution of the confidential
information contained therein, or the taking of any action based on it, is
prohibited. The sender disclaims any liability for the integrity of this
email. Legally binding declarations must be in written form.

Reply via email to