5 Replies Latest reply on Oct 5, 2012 8:51 AM by j4m3s

    Outbound connection from JBoss AS

    gvseghbr

      Hi,

       

      I want to access a REST interface from within an EJB. This EJB is deployed on a local JBoss AS7.

      Extra difficulty, I have to use a certificate to connect to the REST interface's server.

       

      Is there a possibility to use JBoss AS to manage the outbound connections? JBoss' remoting subsystem? outbound-socket-binding?

      How can I get an instance of such a connection from within my EJB?

       

      Kind regards,

      Gregory

        • 1. Re: Outbound connection from JBoss AS
          fabrizio.benedetti

          You can use Apache HttpComponents from within the EJB, or use Jboss Resteasy client.

          For the certificate you have to use a java keystore and set SSL system properties in jboss start script.

          Ex.: -Djavax.net.ssl.keyStore=/path/to/keystore.jks -Djavax.net.ssl.trustStore=/path/to/truststore.jks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.keyStoreAlias=alias

           

          Regards

          /F

          1 of 1 people found this helpful
          • 2. Re: Outbound connection from JBoss AS
            gvseghbr

            Hi Fabrizio,

             

            First of all, thank you for the response.

             

            However, I was hoping there would be a more "managed" solution to this. What I had hoped for, was to be able to use JBoss’ security realms for the SSL and something similar to invoking remote EJBs.

             

            In the option that you propose, I have to manage the ConnectionManager and all connections myself.

             

            Kind Regards,

            Gregory

            • 3. Re: Outbound connection from JBoss AS
              j4m3s

              I use the REST-Easy client from within JBoss to consume external REST services.  It's built on top of Apache Http client so you can use a variety of options including setting headers etc.    I haven't used it with SSL but looking at this StackOverflow question it looks easy enough: http://stackoverflow.com/questions/12369495/accepting-a-self-signed-certificate-in-java

              • 4. Re: Outbound connection from JBoss AS
                fabrizio.benedetti

                James Fellows ha scritto:

                 

                I use the REST-Easy client from within JBoss to consume external REST services.  It's built on top of Apache Http client so you can use a variety of options including setting headers etc.    I haven't used it with SSL but looking at this StackOverflow question it looks easy enough: http://stackoverflow.com/questions/12369495/accepting-a-self-signed-certificate-in-java

                I also would use REST-Easy client.

                Only a precision. In StackOverflow question they talk about SSL configuration server side. From EJB perspective, it needs only SSL client side. It is sufficient to set the system properties as I said and automatically REST-Easy/Apache HttpClient inherits them.

                 

                Regards

                /F

                • 5. Re: Outbound connection from JBoss AS
                  j4m3s

                  You need to check out the apache http4 docs to see what params you need to set.  I shouldn't have included that StackOverflow link - it's not very helpful, sorry. 

                   

                  To configure the apache HTTP4 executor that underpins a RESTeasy request you pass in an ApacheHttpClient4Executor instance as the third parameter into the RESTEasy ProxyFactory.create() method.