1导入ksoap2-android-assembly-2.4-jar-with-dependencies.jar
2加入上网权限:
3导入包
import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
4代码
String nameSpace = http://tempuri.org/; String serviceURL = "http://192.168.10.3:98/TestClothingDRPService/ServicePowerEAI.asmx"; String methodName = "GetHelpFileURL";//方法名 String soapAction = "http://tempuri.org/GetHelpFileURL"; SoapObject request = new SoapObject(nameSpace, methodName); request.addProperty("HCC", "19"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = request; envelope.dotNet=true; HttpTransportSE ht = new HttpTransportSE(serviceURL); ht.debug = true; String result=""; try { ht.call(soapAction, envelope); if (envelope.getResponse() != null) { result= envelope.getResponse().toString(); } else { } } catch (Exception e) { e.printStackTrace(); } TextView tv1=(TextView)findViewById(R.id.textView1); tv1.setText(result);
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>