This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to work with Complex Type Data in JAX WS

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 .

 
Jim Akmer
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am concerned about jaxrpc-mapping.xml file where all Java to WSDL mappings will be mentioned . Any idea Jim ??
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karim Gunjarge
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic