5 Replies Latest reply on Jun 16, 2006 12:31 PM by Christian Betz

    Configure Server Handler With JSR181 EJB Endpoint

    Michael Rother Newbie

      How do you configure to use a Server Handler with JSR181 EJB endpoint? Is there an annototation that allows you to specify handlers?

        • 1. Re: Configure Server Handler With JSR181 EJB Endpoint
          Pablo Javier Santa Cruz Cosp Newbie

          You need:

          * JBoss 4.0.4 WITH EJB3 support
          * JDK 1.5

          Then, the only thing you need to code is:

          import javax.ejb.Stateless;
          import javax.jws.WebMethod;
          import javax.jws.WebService;
          import javax.jws.soap.SOAPBinding;
          
          import py.gov.set.rucas.beans.auth.AuthAddResponse;
          import py.gov.set.rucas.beans.auth.AuthInfoResponse;
          import py.gov.set.rucas.beans.auth.AuthVerifyResponse;
          import py.gov.set.rucas.beans.auth.Param;
          import py.gov.set.rucas.persistence.components.Auth;
          import py.gov.set.rucas.persistence.components.Contributor;
          
          @WebService
          (
           name = "AuthManagement",
           targetNamespace = "http://py.gov.set.services/rucas/simple",
           serviceName = "SimpleService"
          )
          
          @SOAPBinding(style = SOAPBinding.Style.RPC)
          @Stateless
          public class SimpleWebServiceEJB {
          
           static org.apache.log4j.Logger logger = org.apache.log4j.Logger
           .getLogger(SimpleWebServiceEJB.class);
          
           public static final String CURRENT_VERSION = "0.9.1-alpha";
          
           public SimpleWebServiceEJB() {
           super();
           }
          
           @WebMethod
           public String getCurrentVersion()
           {
           return SimpleWebServiceEJB.CURRENT_VERSION;
           }
          
           @WebMethod
           public String reverse(String s)
           {
           StringBuffer sbuf = new StringBuffer(s);
           return sbuf.reverse().toString();
           }
          
          }
          


          After that, deploy into a JAR, and you are done.

          JSR181 rules!

          • 2. Re: Configure Server Handler With JSR181 EJB Endpoint
            Michael Rother Newbie

            Sorry for the confusion. I am trying to add a hook for the Soap Headers by subclassing GenericHandler. I do not know how to wire in the handler in a EJB3 system.

            • 3. Re: Configure Server Handler With JSR181 EJB Endpoint
              Pablo Javier Santa Cruz Cosp Newbie

              Sorry MJ. You lost me...

              I don't know anything about SOAP Handlers...

              Do you have a URL?

              Where can I read more about Schema Type generation? I am facing some problems when using complex types and arrays....

              • 4. Re: Configure Server Handler With JSR181 EJB Endpoint
                B Levin Newbie

                Mate,
                all you need to do is add this annotations:

                ......
                @SOAPBinding(style = SOAPBinding.Style.RPC, use=SOAPBinding.Use.LITERAL)
                /** handlers stuff: */
                @SOAPMessageHandlers({
                @SOAPMessageHandler(
                className = "ur.class.name")
                })

                /** end handlers stuff */

                And your handler looks like:

                public class MyDefaultMessageHandler extends GenericHandler {

                @Override
                public void destroy() {
                // TODO Auto-generated method stub
                super.destroy();
                }

                @Override
                public QName[] getHeaders() {
                // TODO Auto-generated method stub
                return null;
                }

                @Override
                public boolean handleFault(MessageContext arg0) {
                // TODO Auto-generated method stub
                return super.handleFault(arg0);
                }

                @Override
                public boolean handleRequest(MessageContext arg0) {
                }
                }


                Works for me. Have fun, mate.
                JSR 181 rules indeed.

                • 5. Re: Configure Server Handler With JSR181 EJB Endpoint
                  Christian Betz Newbie

                  Hi!

                  I'm reactivating this thread: The above example does not work in jbossws.1.0.1. It results in a ClassCastException:

                  18:26:58,796 ERROR [SOAPFaultExceptionHelper] SOAP request exception
                  java.lang.ClassCastException: de.s2i.db.service.server.handler.LoggingHandler
                   at org.jboss.ws.handler.HandlerChainBaseImpl.addHandlersToChain(HandlerChainBaseImpl.java:124)
                   at org.jboss.ws.handler.HandlerChainBaseImpl.<init>(HandlerChainBaseImpl.java:94)
                   at org.jboss.ws.handler.ServerHandlerChain.<init>(ServerHandlerChain.java:47)
                   at org.jboss.ws.server.ServiceEndpoint.initHandlerChain(ServiceEndpoint.java:347)
                   at org.jboss.ws.server.ServiceEndpoint.initHandlerChain(ServiceEndpoint.java:340)


                  The same happens with the annotation
                  @HandlerChain(file="jar:file:///D:/Programme/jboss-4.0.4.GA/server/default/deploy/Accounting.war!/WEB-INF/classes/handler-chains.xml",name="HandlerChain")


                  Again I would appreciate any help.

                  Bye

                  Chris