REST Service PUT , xml payload structure
for a REST PUT service, im trying to use xml as the payload. My question is can I have the whole payload as xml? or should I do somethi开发者_如何转开发ng like Data=<mydata>......</mydada>
?
basically
<mydata>......</mydada>
or
Data=<mydata>......</mydada>
Sure you can just set the mediaType to be application/xml
just as you can for json or plain text. The first example is valid XML, second one is not. So the first one can be done.
I am not sure what framework you are using. For example if you plan to use Spring you can take a look at an example here.
The basic idea is that you define the media type to be application/xml
. You can also specicfy a marshaller/unmarshaller (ie. using JAXB) if you want to marshal/unmarshal from a Java bean.
精彩评论