public static String sendXMLDataByPost( String url,String xmlData) throws ClientProtocolException, IOException { Integer statusCode = -1; if (httpClient == null) { httpClient = new DefaultHttpClient(); } HttpPost post = new HttpPost(url); StringEntity entity = new StringEntity(xmlData); post.setEntity(entity); post.setHeader("Content-Type", "text/xml;charset=UTF-8"); HttpResponse response = httpClient.execute(post); statusCode = response.getStatusLine().getStatusCode(); System.out.println("返回状态:"+statusCode); // 获取返回数据 HttpEntity repEntity = response.getEntity(); String body = EntityUtils.toString(repEntity,"UTF-8"); return body; }
HttpClient4.4.1 post提交xml
猜你喜欢
转载自lanfei.iteye.com/blog/2209501
今日推荐
周排行