File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes How to work with Complex Type Data  in JAX WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to work with Complex Type Data  in JAX WS " Watch "How to work with Complex Type Data  in JAX WS " New topic
Author

How to work with Complex Type Data in JAX WS

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234


I have deployed a Web service developed using JAXWS in Glass Fish v3 .

My service accepts a String and returns a double[] .

I am able to work with the above mentioned operation (Writtena client for my wsdl and passed a String and got back a double[])

Now my question is , i want to pass a DTO Object to my web service method , please guide me what are the things i need to take care ??

Thanks in advnace .


Save India From Corruption - Anna Hazare.
Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
I am not sure I follow. You have created a web service e.g. using annotations? Create the class you want and declare it as a parameter in your web service. Then use the wsgen tool to generate the wsdl and the required artifacts.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

I am concerned about jaxrpc-mapping.xml file where all Java to WSDL mappings will be mentioned . Any idea Jim ??
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Not very clear, bug here is a suggestion. If you are using code-first approach, then just declare the method as you dish, and use the Pptoktiate tools go generate the WSDL and other artifacts.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Karim Gunjarge
Greenhorn

Joined: Sep 21, 2010
Posts: 4
by reading your information, if you are following code first approch, jax-ws supports complex data type and you can use collection class there. you also need to use annotation to define them.

By sugession is keep your DTO objects aside and create "beans" which will input/output of your message/method that way you will be able to split the layers. and have some code to map these dto to beans and viseversa. Having the beans will help you creating versions also.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks Karim for the reply ,



can you please as what are the annotations are there to define on Collection classes ??


and have some code to map these dto to beans and viseversa.


I assume that Bean and DTO are same , please tell me what is the difference between them ??

Thanks in advance .
Karim Gunjarge
Greenhorn

Joined: Sep 21, 2010
Posts: 4
I refere annotation like : this will help not to create xml tag when there is no values/empty. When you use Collection class, you dont need to have setter method insead you getter to get collection object and add values to that. but for that you need initialize collection object at declaration. see below code.

@XmlElement(required = false, nillable = true)
private List<Integer> myInteger = new ArrayList<Integer>();


When you say DTO i was Considering as Data Transfer Objects. and i was thinking to have Seperate Beans and these dto will b used to transfer beans values to controller.

hope this information will help you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to work with Complex Type Data in JAX WS