5 Replies Latest reply on Jun 12, 2006 12:03 AM by thomas.diesler

    how to invoke a client to jsr181-pojo web service?

    adamzrk

      Hello again

      A have successfully deployed jsr181-pojo web service as web application (war) and a client application w jar file. My question is - how to write a (real) client which would invoke web service client (jar) deployed on jboss? Some example code will be very helpful :) I have tried this code:

      public static void main(String[] args) throws Exception{
      new ClientTest().testTrivialAccess();

      }

      public void testTrivialAccess() throws Exception
      {
      InitialContext iniCtx = getInitialContext();
      Service service = (Service)iniCtx.lookup("java:comp/env/service/TestService");
      JSEBean01 port = (JSEBean01)service.getPort(JSEBean01.class);
      String person = "Kermit";
      String product = "Ferrari";
      String status = port.echo(person);

      }

      protected InitialContext getInitialContext() throws NamingException
      {
      InitialContext iniCtx = new InitialContext();
      Hashtable env = iniCtx.getEnvironment();
      env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.factory.url.pkgs","org.jboss.naming.client");
      env.put("java.naming.provider.url","jnp://localhost:1099");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
      env.put("j2ee.clientName", "jbossws-client");
      return new InitialContext(env);
      }

      but i see only stack trace of exception...
      I wish the code would be simpler - without lines with env.put.... but i think it's not possible...
      Help me!

      Thanks in advance,
      Adam