4 Replies Latest reply on Jun 20, 2011 8:23 AM by jdabrowski

    How to define context-root or URL for web service?

    baradon

      Hi,

       

      I would like to define the URL under which a web service is reachable.  My web service is based on a stateless session bean.  I know, that there is the @WebContext annotation, but I would like to keep my code free from any JBoss specific things.

       

      The session bean/web service is implementen in a JAR file, which then is included in an EAR file.  In fact, I have several JAR files, some of them implementing their own web services.  All of them are included in the EAR file.  This EAR file is project specific, and I would like to define the URL (or at least the context root) in that file, leaving the JAR file untouched.

       

      Is such a solution possible?  If yes, how can I achieve that?

       

      Thanks and best regards,

       

       

          Heiner

        • 1. How to define context-root or URL for web service?
          twieden

          Hello Heiner,

           

          i'm not one of the WebService experts - just another user ...

           

          In my expierience the idea to keep an application independant from the application server follows the java idea, but in reality i never seen the a project changed the server platform when in was running. So i would propose you to take the dependency to jboss - if the server will be changed really, you have to adapt your code anyway, as other app servers have their specialities too.

           

          I dont excatly know from where jboss takes the context root, may be you check

          - the service element in the WSDL

          - try to use the Endpoint publish() method (see http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/ )

           

          Hope this helps in any way ...

           

          Best regards, Timo

          • 3. How to define context-root or URL for web service?
            baradon

            Hi Alessio,

             

            thanks for the link.  It partly solved my problem.  I now can define the URL via the jboss.xml file.  The only thing is, that this file needs to be in the ejb-jar. Is there a way to configure this directly in the ear-file, without touching the ejb-jar?

             

            @Timo:  I agree, that the actual artefact deployed in an application server will most likely not be portable.  That's fine for me.  My problem is, that we have some JARs treated as an AS-independant product.  These JARs will be used in project-specific (and therefore AS-specific) EARs.

             

            I know that I could now re-pack the ejb-jar and add the project specific jboss.xml file.  But for me it would be a cleaner solution, if it could be configured at EAR level.

             

             

            Best regards,

             

            Heiner

            • 4. Re: How to define context-root or URL for web service?
              jdabrowski

              So there is no way to set contextRoot at ear level?

               

              I need context root because I have more then one ear in some servers and I would like to separate the addresses and I can't define it in @WebContext as was explained in FAQ without default values (some beans can go to different ears).