• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get structred XML Response in Webservice

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using jersey webservices. (REST based calls).
i am getting xml response by using
@Produces(MediaType.APPLICATION_XML).

Here i have a class called BaseData (which annotated by @XmlRootElement)
and subresource class called MyMetaData(which annotated by @XmlRootElement)

here i am getting xml as (subresource with 2 address)

<BaseData>
<description>Desc1</description>
<MyMetaData>
<address>aaaaaaaaaa</address>
<address>bbbbbbbbbb</address>
<zipcode>111111</zipcode>
<zipcode>222222</zipcode>
<city>Chennai</city>
<city>Trichy</city>
</MyMetaData>
<name>Thilsen</name>
<age>28</age>
<title>Mr</title>
</BaseData>

But i need to get it as

<BaseData>
<description>Desc1</description>
<MyMetaData>
<MetaData>
<address>aaaaaaaaaa</address>
<zipcode>111111</zipcode>
<city>Chennai</city>
</MetaData>
<MetaData>
<address>bbbbbbbbbb</address>
<zipcode>222222</zipcode>
<city>Trichy</city>
</MetaData>
</MyMetaData>
<name>Thilsen</name>
<age>28</age>
<title>Mr</title>
</BaseData>

How can i achieve this?
Please suggest me!

Thanks & Regards,
Thilsen
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a class say MetaData with three data members - city, zipcode and address.
In MyMetaData class, you need have a data member which would be an array of MetaData objects.
Hopefully that should solve your problem.
 
thilsen kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes , i solved tat.. thanks for your reply.

Thilsen.
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic