6 Replies Latest reply on Oct 1, 2008 11:21 AM by Peter Johnson

    Steless Session bean as Webservice

    Dasari Prasad Newbie

      i wrote one Stateless bean like

      ( in mustang version and jboss5.0.0 CR2)

      SimpleWS.java (interface)

      
      @WebService
      @SOAPBinding(style=Style.RPC)
      public interface SimpleWS extends Remote
      {
       @WebMethod
       public String greet(String person)
       throws RemoteException;
      }
      
      SimpleWSBean.java
      
      @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";
       }
      
      }
      and deployed success fully
      
      but when i run client like
      SimpleWSClient.java
      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);
       }
       }
      
      }
      
      i am getting the error
      
       [java] ..org.jboss.ws.core.jaxrpc.client.ServiceImpl@1a62c31
       [java] ##org.jboss.ws.core.jaxrpc.client.CallImpl@3020ad
       [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
      
      
      same i could able to run with tiger version and jboss422 with no problem


        • 1. Re: Steless Session bean as Webservice
          Peter Johnson Master

          Which CR2 package did you download? jboss-5.0.0.CR2.zip or jboss-5.0.0.CR2-jdk6.zip? Since you are using jdk 1.6 you need to download jboss-5.0.0.CR2-jdk6.zip.

          Based on the error message, I suspect that you downloaded the wrong package because the "setProperty must be overridden" is a know issue when using JDK 1.6, and I know that there is a wiki page that discusses this but I cannot find it.

          • 2. Re: Steless Session bean as Webservice
            Dasari Prasad Newbie

            I had downloaded JBoss-5.0.0 CR2-jdk6.zip only.

            but once again i am downloading and will check

            • 3. Re: Steless Session bean as Webservice
              Peter Johnson Master

              You could also try using wsconsume to generate the client stubs and then use those stubs to write your client. The client code will be much simplified:

              public static void main(..) {
              SimpleWSBeanService svc = new SimpleWSBeanService();
              SimpleWS simple = svc.getSimpleWSBeanPort();
              String reply = simple.greet("xxx");
              }


              Also, the use of the Remote interface and annotation is not necessary.

              Works for me just fine on CR2 with JDK5 or 6.

              • 4. Re: Steless Session bean as Webservice
                Dasari Prasad Newbie

                i had used wsconsume like this

                >wsconsume ---------------endpoint-address?\WSDL
                
                it has given new classfiles as mentioned in your program
                
                but if i run
                i got
                Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/AttachmentPartImpl
                 [java] at com.sun.xml.ws.message.AttachmentUnmarshallerImpl.<clinit>(AttachmentUnmarshallerImpl.java:55)
                 [java] at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit$PartBuilder.readResponse(ResponseBuilder.java:635)
                 [java] at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit.readResponse(ResponseBuilder.java:599)
                 [java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242)
                 [java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
                 [java] at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
                 [java] at $Proxy22.greet(Unknown Source)
                 [java] at com.htc.htcws.SimpleWSClient.main(Unknown Source)
                 [java] Caused by: java.lang.ClassNotFoundException: com.sun.xml.messaging.saaj.soap.AttachmentPartImpl
                 [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                 [java] at java.security.AccessController.doPrivileged(Native Method)
                 [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                 [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                 [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
                 [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                 [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
                 [java] ... 8 more
                
                 my classpath is
                
                <property name="deploydir" value="${JBOSS_HOME}\server\default\deploy" />
                 <property name="client.dir" value="${JBOSS_HOME}\client" />
                 <property name="extended.dir" value="${JBOSS_HOME}\lib\endorsed" />
                 <property name="java-lib.dir" value="c:\jdk1.6.0\lib" />
                 <property name="jboss-lib.dir"
                 value="${JBOSS_HOME}\lib"/>
                
                
                 <path id="cpath" >
                
                 <fileset dir="${client.dir}" includes="**/*.jar" />
                 <fileset dir="${extended.dir}" includes="**/*.jar" />
                 <fileset dir="${java-lib.dir}" includes="tools.jar" />
                 <fileset dir="${axis-lib}" includes="saaj.jar" />
                
                 <pathelement path="${cls}" />
                 <pathelement path="." />
                 </path>
                
                which jars i have to put in classpath.
                


                • 5. Re: Steless Session bean as Webservice
                  Dasari Prasad Newbie

                  Thank you ,

                  i downloaded saaj-impl.jar put it in jboss\client folder and i could
                  sess my client running well

                  • 6. Re: Steless Session bean as Webservice
                    Peter Johnson Master

                    Where in your code are you referencing Sun-specific classes (com/sun/xml/messaging/saaj/soap/AttachmentPartImpl)? You should not need that.

                    Are you trying to use Axis (I noticed it in your classpath)? You do not need Axis with CR2.