我有个小问题。我正在http://www.thomas-bayer.com/sqlrest/CUSTOMER演示REST服务上测试我的Android REST类。
Get方法还可以,但我不知道如何使用HttpPut或HttpPost。
HttpPut request = new HttpPut("http://www.thomas-bayer.com/sqlrest/CUSTOMER/-2223");但是,我不知道如何将XML数据添加到此对象以放到服务器上,例如:
<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>非常感谢你的回答。
发布于 2011-08-30 21:58:34
您必须通过setEntity设置XML内容,其中Entity必须是StringEntity。
mystr = ... // your XML
HttpPut request= new HttpPut(url);
request.setEntity(new StringEntity(mystr));https://stackoverflow.com/questions/7244293
复制相似问题