0

I have below XML response from third party webservice.

How can I populate XML values into Java POJO ? Please help me!

Thanks!

5
  • 1
    What have tried? Did you trying parsing the result using a DOM or SAX parser? Commented Oct 20, 2014 at 5:26
  • I dont know which properties do I need to place in POJO since the xml has all nested elements. Please help me. Commented Oct 20, 2014 at 5:27
  • How are we suppose to know, it's your data...? Commented Oct 20, 2014 at 5:29
  • I need to capture all <aws:Data> elements. Commented Oct 20, 2014 at 5:31
  • But what have you tried? What problems did you hit with those attempts...? Commented Oct 20, 2014 at 5:39

2 Answers 2

0

When you are generating the web service's client side from a given WSDL it should generate for you the POJO classes defined in the WSDL (in your case, you should have "TrafficHistoryResponse" which wraps "OperationRequest" and "TrafficHistoryResult" which wraps "Alexa" which wraps "TrafficHistory" which wraps "Range", "Site", "Start" and "HistoricalData" that holds "Data" array).

Please, refer to the following link for additional information about importing a WSDL: How to generate java classes from WSDL file

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. I dont have wsdl.It is a REST call.
Try checking this one (it explains how to generate a client side for RESTFUL web services): stackoverflow.com/questions/2689122/…
0

I think you need to create a stub class which is a pojo class in which all the xml tags will be turned into instance variables and the nesting of xml tags will be defined as nested pojo classes.

Then by applying proper mapping from webservice's response to this stub class your response data will be automatically populated in Java POJO class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.