首先别人 已经做了一个库
http://sourceforge.net/projects/ksoap2/
http://code.google.com/p/ksoap2-android/wiki/SourceCodeHosting?tm=4
如果想自己写一个
1.传递简单html 以及数据问题
HttpClient httpclient = new DefaultHttpClient();
// 你的地势
HttpPost httppost = new HttpPost("http://192.71.100.21:8000");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
// 数据传送的
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata","AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response;
response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
2.传递xml
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 {
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
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);
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient .execute(httppost);
response.put("HTTPStatus",httpResponse.getStatusLine().toString());