users@glassfish.java.net

A question about Stateful Web Srevice built with Glass Fish Jax-Ws

From: <glassfish_at_javadesktop.org>
Date: Sat, 15 Nov 2008 11:57:07 PST

I use the Jaxs-WS to build a stateful web service. The service looks as follwo:

    code:

     
    @Stateful
    @WebService
    @Addressing
    public class MyStatefulWsImpl {
            private int balance = 0;
            private final String id;
     
            public MyStatefulWsImpl(String id) {
                    this.id = id;
            }
     
            public String getId() {
                    return id;
            }
     
            @WebMethod
            public synchronized void deposit(int amount) {
                    balance += amount;
            }
     
            @WebMethod
            public synchronized int getBalance() {
                    return balance;
            }
     
    }
     



And the client looks as follow:

    code:

       
    public class MyJaxWsStatefulClient
    {
        public static void main( String[] args )
        {
                MyStatefulWsImplService myStatefulWsImplService = new MyStatefulWsImplService();
                MyStatefulWsImpl myStatefulWsImpl = myStatefulWsImplService.getMyStatefulWsImplPort();
                myStatefulWsImpl.deposit(23);
                System.out.println(myStatefulWsImpl.getBalance());
        }
    }



But as I run the client, I got exception as follow:

    code:

      
    Exception in thread "main" javax.xml.ws.WebServiceException: {http://stateful.ws.jax.weichen.com/}MyStatefulWsImplService is not a valid service. Valid services are:
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:204)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:172)
            at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
            at javax.xml.ws.Service.<init>(Service.java:56)
            at com.weichen.jax.ws.client.stub.MyStatefulWsImplService.<init>(MyStatefulWsImplService.java:46)
            at com.weichen.jax.ws.stateful.client.MyJaxWsStatefulClient.main(MyJaxWsStatefulClient.java:15)
[Message sent by forum member 'thomas2004' (thomas2004)]

http://forums.java.net/jive/thread.jspa?messageID=316936