I’ve just started using CXF 2.4 to expose some methods in an existing web application. One of the methods returns a complex type object – Employee which has an Address object as a property.
The employee object looks like:
public class Employee implements Serializable {
private String gid;
private String name;
private Address employeeAddress;
//...getters and setters omitted
}
The method signature in the service side interface looks like:
Employee getEmployee(@WebParam(name="gid") String gid);
On the client side I used the CXF WsdlToJava utility to generate my client side stubs from the server wsdl address and was happily using the Employee object in my client web application.
Today a co-worker pointed out to me that I shouldn’t be using the webservice generated objects in my client application code. Instead I should create an Employee class specific to my client web app and copy the properties from the web service Employee object to my application Employee object to prevent the web service code ending up throughout the code base.
To me this seems like overkill, in effect I’ll create an Employee class plus an Address class and copy properties back and forth between objects of those types and those of the webservices.
In my application I’m displaying the details of the Employee object on a JSP page but not doing much else with it.
So to sum up my question – when using webservice calls in CXF which return complex type objects, should you always use separate client application specific objects which copy the properties of the webservice generated objects? Is there a rule to use or does it depend on how complex the objects returned are and what the client application intends to do with them (e.g. just display them, edit them and return them, store them in a client application db.)
Thanks
Darren
I don’t see any problem in using webservice generated object on the client side.
And creating own class and move the prperties back and forth is just a time killing process.
When tool is providing you the implementation feature why we need to manually do the changes.If there is a valid point then need to be figure out.
So my answear is you can work with the webservice generated Employee class for your implementation.