开发者

How to add XML data to HttpPut object?

开发者 https://www.devze.com 2023-03-31 23:11 出处:网络
I have a small problem. I am testing my Android REST class on http://www.thomas-bayer.com/sqlrest/CUSTOMER DEMO REST service.

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));
0

精彩评论

暂无评论...
验证码 换一张
取 消