post 发送xml

来源:互联网 发布:c语言排序算法最快 编辑:程序博客网 时间:2024/05/22 08:18
HttpPost httppost = new HttpPost(SERVICE_EPR);          StringEntity se = new StringEntity(SOAPRequestXML,HTTP.UTF_8);se.setContentType("text/xml");  httppost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");httppost.setEntity(se);  HttpClient httpclient = new DefaultHttpClient();BasicHttpResponse httpResponse =     (BasicHttpResponse) httpclient.execute(httppost);


添加list

public void postData() {         // Create a new HttpClient and Post Header           HttpClient httpclient = new DefaultHttpClient();           HttpPost httppost = new HttpPost("http://10.10.4.35:53011/");         try {               // Add your data               List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);               nameValuePairs.add(new BasicNameValuePair("Content-Type", "application/soap+xml"));                            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));                  // Where/how to add the XML data?             // Execute HTTP Post Request               HttpResponse response = httpclient.execute(httppost);           } catch (ClientProtocolException e) {               // TODO Auto-generated catch block           } catch (IOException e) {               // TODO Auto-generated catch block           }       }


0 0
原创粉丝点击