android程序调用asmx页面

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;

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);

你可能感兴趣的:(android程序调用asmx页面)