3 Replies Latest reply on Feb 14, 2005 2:51 PM by Thomas Diesler

    Configuring Handlers

    Marcelo Pitanga Newbie

      Hi all,

      In the RI ( Reference Implementation ) the file config.xml is used for this operation.

      How i configured this handler as part of a handler chain at Jboss?

      my handler is :

      public class SoapRpcInterceptor extends GenericHandler {
      
       HandlerInfo hInfo;
       String nomeHandle;
      
       public void init(HandlerInfo info) {
       hInfo = info;
       nomeHandle = (String)hInfo.getHandlerClass().getSimpleName();
       }
      
       public QName[] getHeaders() {
       return hInfo.getHeaders();
       }
      
       public boolean handleRequest(MessageContext msgCtx) {
       try {
       Date dtInicio = new Date();
       msgCtx.setProperty("dtInicio", dtInicio);
       System.out.println("Request (handler)->"+nomeHandle+" Inicio="+dtInicio);
       SOAPMessageContext smc = (SOAPMessageContext)msgCtx;
       SOAPMessage msg = smc.getMessage();
       msg.writeTo(System.out);
       }
       catch (Exception e) {
       System.out.println("Error Request:"+e.getMessage());
       }
       return true;
       }
      
      /*
       * (non-Javadoc)
       * @see javax.xml.rpc.handler.Handler#handleResponse(javax.xml.rpc.handler.MessageContext)
      */
       public boolean handleResponse(MessageContext msgCtx) {
       try {
       System.out.println("Response");
       Date dtIni = (Date) msgCtx.getProperty("dtInicio");
       System.out.println("dtInicio="+dtIni);
       Date dtFinal = new Date();
       System.out.println("Response="+dtFinal);
       long duracao = dtFinal.getTime()-dtIni.getTime();
       System.out.println("Duracao:"+duracao);
       }
       catch (Exception e) {
       System.out.println("Error Response: "+e.getMessage());
       e.printStackTrace();
       }
       return true;
       }
      
       /* (non-Javadoc)
       * @see javax.xml.rpc.handler.GenericHandler#handleFault(javax.xml.rpc.handler.MessageContext)
       */
       public boolean handleFault(MessageContext arg0) {
       System.out.println("Fault");
       return true;
       }
      }
      




        • 1. Re: Configuring Handlers
          Thomas Diesler Master

          If its a server side handler in webservices.xml
          If its a client side handler in <service-ref> in ejb-jar.xml, web.xml, application-client.xml

          • 2. Re: Configuring Handlers
            Marcelo Pitanga Newbie

            Hi Thomas,

            Thank´s for reply.

            I do this configuration and the handler work´s fine.

             <webservice-description>
             <webservice-description-name>HelloWorldService</webservice-description-name>
             <wsdl-file>WEB-INF/wsdl/hello.wsdl</wsdl-file>
             <jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
             <port-component>
             <port-component-name>HelloWorld</port-component-name>
             <wsdl-port>HelloWorld</wsdl-port>
             <service-endpoint-interface>com.myapp.HelloWorld</service-endpoint-interface>
             <service-impl-bean>
             <servlet-link>HelloWorldServlet</servlet-link>
             </service-impl-bean>
             <handler>
             <handler-name>SoapRpcInterceptor_1</handler-name>
             <handler-class>middlog.interceptor.SoapRpcInterceptor</handler-class>
             </handler>
             </port-component>
             </webservice-description>
            


            I'm creating this handler for logging the operations at the web services. Exists a way for get informations on the handler-name, port-component-name, webservice-description-name... of the webservice.xml ?


            • 3. Re: Configuring Handlers
              Thomas Diesler Master

              Not in a portable way (standard) way. In JBoss you can go to the jboss.ws4ee:service=AxisService and obain the PortComponentInfo for a given serviceID.

              Form that you should be able to navigate to the info you need.