1 Reply Latest reply on May 23, 2019 10:11 AM by mbsakho

    EJB Invocation Over HTTP

    mbsakho

      Hello everyone,

      I would like to use the EJB invocation over HTTP to call EJB deployed on Wildfly 16 or EAP7.2 since both support this feature.

      The EAP documentation states to configure both the client and the server [1].

      Configuring the server is straight forward, but I'm a little bit confused in the client side because of the lack of example.

      Do we have an example of a client side implementation?

      The doc only states the following:

      To perform the HTTP invocation, you must use the http URL scheme and include the context name of the HTTP invoker, wildfly-services. For example, if you are using remote+http://localhost:8080 as the target URL, in order to use the HTTP transport, you must update this to http://localhost:8080/wildfly-services.

      Do we still need JNDI lookup and initial context setting and all the stuff we used to do while using remoting like the following extract ?

      Is it just the Context.PROVIDER_URL that will change?

      If yes, what is the value added with this protocole?

      public class Client {

          public static void main(String[] args)

                  throws NamingException, PrivilegedActionException, InterruptedException {

              InitialContext ctx = new InitialContext(getCtxProperties());

              String lookupName = "ejb:/server/HelloBean!ejb.HelloBeanRemote";

              HelloBeanRemote bean = (HelloBeanRemote)ctx.lookup(lookupName);

              System.out.println(bean.hello());

              ctx.close();

          }

          public static Properties getCtxProperties() {

              Properties props = new Properties();

              props.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());

              props.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");

              props.put(Context.SECURITY_PRINCIPAL, "joe");

              props.put(Context.SECURITY_CREDENTIALS, "joeIsAwesome2013!");

              return props;

          }

      }

      Can someone show me client code example?

       

      [1]=https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.2/html-single/developing_ejb_applications/index#ejb_invocation_over_http