2 Replies Latest reply on Mar 30, 2008 9:37 PM by htcprasad

    Ejb3.0 Stateless session bean as webservice in jboss4.2.2

    htcprasad

      I had created three files like

      SimpleWS.java

      package com.htc.htcws;

      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import java.rmi.Remote;
      import java.rmi.RemoteException;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;


      @WebService
      @SOAPBinding(style=Style.RPC)
      public interface SimpleWS extends Remote
      {
      @WebMethod
      public String greet(String person)
      throws RemoteException;
      }

      SimpleWSBean.java
      package com.htc.htcws;

      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;

      @Stateless
      @Remote(SimpleWS.class)
      @WebService(endpointInterface="com.htc.htcws.SimpleWS")
      @SOAPBinding(style=SOAPBinding.Style.RPC)
      public class SimpleWSBean implements SimpleWS
      {
      @WebMethod
      public String greet(String person)
      {
      return "Hi "+person+" all Good Wishes for Tamil New Year's Day";
      }

      }

      SimpleWSClient.java

      package com.htc.htcws;
      import javax.xml.rpc.ServiceFactory;
      import javax.xml.rpc.Service;
      import javax.xml.namespace.QName;
      import java.net.URL;
      import org.apache.log4j.Logger;
      import org.apache.log4j.FileAppender;
      import org.apache.log4j.HTMLLayout;
      import javax.xml.transform.stream.StreamSource;
      import javax.xml.ws.Dispatch;
      import javax.xml.ws.Service.Mode;
      import javax.xml.ws.Response;
      import java.io.StringReader;

      public class SimpleWSClient
      {
      static Logger logger;

      public static void main(String[] args)
      {
      final String _NAMESPACE = "http://htcws.htc.com/";
      final String _SERVICE = "SimpleWSBeanService";


      try
      {
      logger = Logger.getRootLogger();
      logger.addAppender(new FileAppender(new HTMLLayout(),
      "mylog1.log",true));


      URL url =
      new URL("http://127.0.0.1:10080/simpws/SimpleWSBean?wsdl");

      QName qName = new QName(_NAMESPACE,_SERVICE);
      if(args.length!=1)

      {
      System.out.print("Give the person-name as args[0]");
      System.exit(1);
      }



      ServiceFactory sFactory = ServiceFactory.newInstance();

      Service service = sFactory.createService(url,qName);

      System.out.println(".."+service);

      SimpleWS invoker =
      (SimpleWS)service.getPort(SimpleWS.class);
      System.out.println("##"+invoker);

      String res = invoker.greet(args[0]);

      System.out.println("Response is::"+res);
      }
      catch(Exception ex)
      {
      System.err.println("Caught the exception as"+ex);
      }
      }

      }

      the bean getting deployed.but whie running client the error is

      java:
      [java] ..org.jboss.ws.core.jaxrpc.client.ServiceImpl@b8c8e6
      [java] ##org.jboss.ws.core.jaxrpc.client.CallImpl@1542a75
      [java] Caught the exception asjava.rmi.RemoteException: Call invocation failed; nested exception is:
      [java] java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage



      My os is windows vistas ,browser is firefox beta4.0

      can you please suggest where the error is or how to use Dispatch,Response objects here
      mail is dtrprasad@gmail.com