REST webservice that consumes XML



I am learning REST webservice and confused about some concepts. I want to create a RESTful webservice that consumes an XML like:



<?xml version="1.0" encoding="UTF-8"?>
<emp:EmployeeEntry xmlns:emp="http://ift.tt/1sKyPs7">
<emp:number>12345</emp:number>
<emp:name>George</emp:name>
<emp:date>2015-04-03</emp:date>
<emp:address>
<emp:city>Paris</emp:city>
<emp:street>East 35</emp:street>
</emp:address>
</emp:EmployeeEntry>


So, If I want to create a restful webservice that consumes this XML, How would be the signature of my method?



public creatEmp(XML xml);


Should it be like this? (Because I saw some examples of methods that consume XML, but they are taking parameter as main entiry object eg; Employee I don't understand how a method that consumes XML accepts and Entity object as parameter)


Also, If the method is given XML as parameter, do I have to implement parsing logic in the method then create Employee object from that and the start the main create logic?


I have some knowledge gaps, please suggest me some examples or some good tutorials.


No comments:

Post a Comment