I have a small problem. I am testing my Android REST class on http://www.thomas-bayer.com/sqlrest/CUSTOMER DEMO REST service.
Get met开发者_如何学Pythonhod is OK, but I don't know how to use HttpPut or HttpPost.
HttpPut request = new HttpPut("http://www.thomas-bayer.com/sqlrest/CUSTOMER/-2223");
But then I don't know how to add to this object XML data to put on server, for example:
<CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink">
<ID>2</ID>
<FIRSTNAME>Rick</FIRSTNAME>
<LASTNAME>Cortés Ribotta</LASTNAME>
<STREET>Calle Pública "B" 5240 Casa 121</STREET>
<CITY>Sydney100</CITY>
</CUSTOMER>
Thank you very much for answer.
You have to set the XML content via setEntity
where the Entity
has to be a StringEntity
.
mystr = ... // your XML
HttpPut request= new HttpPut(url);
request.setEntity(new StringEntity(mystr));
精彩评论