Java web service; methods are not generated
I have a simple web service. One of the public methods returns a Java Data object. This data class has a "getName ()" method. I compile the project, run "wsgen" on it and start the service (using the built-in JDK6 HTTP server, not tomcat or glassfish, etc.).
So far so good, I can see the wsdl in my browser at the corresponding url.
However, when I try to import this wsdl into another project, the import process successfully creates the "Data" class (which is the class found in the server project), but there are no methods for this class, so I cannot do something like "data. getName () ".
My problem is that the getName () method exists in the Data class in the server project, but in the client project, although the Data class is created, the getName () method is not created by the wsdl import process.
What am I doing wrong?
a source to share
WSDL does not contain any information about the logic in the methods, and therefore you cannot generate code for internal objects.
The simple solution is to replace the generated client-side class with the same class you use on the server-side, however this may be considered bad style.
Objects passed to WS should be simple data holders without special logic for them, you are not limited to primitive types, JAXB will handle even very complex objects, but you cannot exclude the possibility of copying custom logic from server to client, this behavior cannot be standardized and will lead to code duplication.
a source to share
It cannot work if both client and server do not have a JAR file in the CLASSPATH that lets them know what "Data" is. You need to create a generic JAR that you can distribute.
Putting objects in a web service signature is too fragile. Non-Java clients can never use you; any changes to your classes will pulse throughout the system.
It is more common practice to start with a contract and express it in terms of XML Schema, JSON, or REST, and let clients and servers map that data into whatever objects they deem appropriate. I would recommend that your webservice use this approach too.
a source to share