java如何通过post方式给某地址传递xml参数

我正在做一个关于天猫的接口,功能为发布一个物流订单,订单传输格式为xml,请问大家应该怎么写(最好不要使用第三方的jar包)。

第1个回答  推荐于2016-11-02
/**
* 响应xml
* @param response
* @param content
*/
public static void responseContent(HttpServletResponse response,String content){
try {
//把xml字符串写入响应
byte[] xmlData = content.getBytes();

response.setContentLength(xmlData.length);

ServletOutputStream os = response.getOutputStream();
os.write(xmlData);

os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
第2个回答  2013-08-22
apache 有个httpClient的类。你用那个类post就好了。 怎么设置请求参数,具体去看文档。
相似回答