有关Android访问.net的 webservice。。。。很急。。。。
我现在想在Android客户端向.net 服务端发送一段json,然后接收一段xml数据 发送代码如下
public static InputStream postFromHttpClient(String path, Map<String, String> params, String encode) throws Exception { // 用于存放请求参数 List<NameValuePair> formparams = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> entry : params.entrySet()) { formparams.add(new BasicNameValuePair(entry.getKey(), entry .getValue())); } UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, encode); HttpPost httppost = new HttpPost(path); System.out.println(entity.toString()); httppost.setEntity(entity); // 看作是浏览器 HttpClient httpclient = new DefaultHttpClient(); // 发送post请求 HttpResponse response = httpclient.execute(httppost); // return readStream(response.getEntity().getContent()); System.out.println(response.getEntity().getContent()); return response.getEntity().getContent(); }