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
Post a Comment