https://simpligility.github.io/ksoap2-android/index.htmlhtml
https://oss.sonatype.org/content/repositories/ksoap2-android-releases/java
com>google>code>ksoap2-android>ksoap2-android-assemblyandroid
private final String serviceNameSapce = "http://192.168.20.135:8090/"; private final String serviceUrl = "http://192.168.20.135:8090/TestService.asmx"; private final String serviceMethod = "HelloWorld"; private final String serviceAction = "http://192.168.20.135:8090/HelloWorld"; private String strResult = "";
new Thread(new Runnable() { @Override public void run() { //建立HttpTransportSE傳輸對象,serviceUrl是webservice提供服務的url HttpTransportSE httpTransportSE = new HttpTransportSE(serviceUrl); //使用SOAP1.1協議建立Envelop對象,根據服務端WebService的版本號設置SOAP協議的版本號 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //實例化SoapObject對象,第一個參數表示命名空間,第二個參數表示要調用的WebService方法名 SoapObject soapObject= new SoapObject(serviceNameSapce, serviceMethod); //設置調用方法的參數值,若是沒有參數,能夠省略 //soapObject.addProperty("theCityCode", cityName); envelope.bodyOut = soapObject; envelope.dotNet = true; try { //調用webservice httpTransportSE.call(serviceAction, envelope); //獲取服務器響應返回的SOAP消息 if(envelope.getResponse() != null){ SoapObject resultSoap = (SoapObject)envelope.bodyIn; strResult = resultSoap.getProperty(0).toString(); mHandler.sendEmptyMessage(0x002); } } catch (IOException | XmlPullParserException e) { e.printStackTrace(); } } }).start();