Unmarshalling issue during Spring Rest Service call -


calling rest webservice using spring rest template follows-

responseentity<string> response = resttemplate.exchange(builder.build().encode().touri(), httpmethod.get, entity, string.class);  

and output in string format as

<info xmlns="http://schemas.test.org/2009/09/tests.new" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <firstname>firstname</firstname> <lastname>lastname</lastname> <testguid>guid</testguid> <testuid>1</testuid> <token>token</token> <testuserid>14</testuserid> </info> 

when trying unmarshal java class follows

responseentity<info> response = resttemplate.exchange(builder.build().encode().touri(), httpmethod.get, entity, info.class) 

the info class defined

@xmlrootelement(name = "info", namespace = "http://schemas.test.org/2009/09/tests.new") public class info implements serializable{      private string firstname;     private string lastname;     private string testguid;     private string testuid;     private string token;     private string testuserid;      //getters , setter  }    

get values of info class null firstname=null..

could tell missing? thanks

you need map java class this

@xmlrootelement(name = "info", namespace = "http://schemas.test.org/2009/09/tests.new") @xmlaccessortype(xmlaccesstype.field) public class info implements serializable{      @xmlelement(name="firstname")     private string firstname;     @xmlelement(name="lastname")     private string lastname;     @xmlelement(name="testguid")     private string testguid;     @xmlelement(name="testuid")     private string testuid;     @xmlelement(name="token")     private string token;     @xmlelement(name="testuserid")     private string testuserid;      //getters , setter  }    

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -