users@jax-ws.java.net

Class Webmethod return type

From: Prótár Gábor <pgabor_at_freemail.hu>
Date: Mon, 26 Feb 2007 18:46:51 +0100

Hello,

 

I don't know is this the right place to send this question. Sorry if it
isn't, please help me find the solution. This is my first post on this list.

 

I'm having a problem with a webmethod which has a class return type. Here is
a little example:

 

- - - - - - - - - - WS Parameter class begin - - - - - - - - - -

public class MyResult {

    public MyResult () {

    }

    

    public String getVersion() {

        return "v0.1 ß";

    }

    

    public long[] getValues() {

        long[] ids = new long[3];

        ids[0] = 123;

        ids[1] = 234;

        ids[2] = 345;

        

        return ids;

    }

    

}

- - - - - - - - - - WS Parameter class end - - - - - - - - - -

 

- - - - - - - - - - Webmethod begin - - - - - - - - - -

    @WebMethod

    public MyResult TryMyResult()

    {

        MyResult result = new MyResult ();

        return result;

    }

- - - - - - - - - - Webmethod begin - - - - - - - - - -

 

I'm using Netbeans v5.5 and the integrated tools for JAX-WS.

 

These are the steps what I have tried:

1. Create a webservice in a web project.
2. Add the following code to it and issue the run command from netbeans
project menu.

 

3. Create a simple java command line test application.
4. Add a webservice client from the project ->new menu.
5. Give it the running webservice WSDL's URL.
6. It generates the webservice stub, and it can be used from the code.
7. After I tried to reach the result.getValues() or result.getVersion
from the client, I found this class:

 

- - - - - - - - - - Generated Stub stub begin - - - - - - - - - -

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "eredm")

public class MyResult {

 

 

}

- - - - - - - - - - Generated Stub stub end - - - - - - - - - -

 

- - - - - - - - - - Generated Stub stub end - - - - - - - - - -

        try { // Call Web Service Operation

            abc.ExtesztService service = new abc.ExtesztService();

            abc.Exteszt port = service.getExtesztPort();

 

            // TODO process result here

            MyResult res = port.TryMyResult ();

 

            //!!!!!!!!!!!!!!!!!!!!!!!!!! res.getValues() and
res.getVersion() missing here!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

            System.out.println("Result = "+res);

        } catch (Exception ex) {

            // TODO handle custom exceptions here

        }

- - - - - - - - - - Generated Stub stub end - - - - - - - - - -

 

The generated code doesn't have any methods. Please help me understand this.
Is this the way how must work or not? If it is not, then how can I fix this?

 

Thanks for your time!

 

Best Regards,

Gábor

 

PS: sory for my bad english. :-)