Android和Asp.Net WebService NAMESPACE,SOAP_ACTION

时间:2014-08-10 11:31:06

标签: android android-ksoap2 android-webservice

我无法理解这段代码是真还是假:

private final String  NAMESPACE   = "http://aspamng.jahanmir.ir/";
private final String  URL         = "http://aspamng.jahanmir.ir/CustomerService.asmx";
private final String  SOAP_ACTION = "http://aspamng.jahanmir.ir/fake";
private final String  METHOD_NAME = "fake";

这是我的网站服务网站:http://aspamng.jahanmir.ir/。如果我向伪元素发送13,Web服务应该响应。事实上,我理解NAMESPACESOAP_ACTION是真还是假?

这是我的代码:

private final String  NAMESPACE   = "http://aspamng.jahanmir.ir/";
private final String  URL         = "http://aspamng.jahanmir.ir/CustomerService.asmx";
private final String  SOAP_ACTION = "http://aspamng.jahanmir.ir/fake";
private final String  METHOD_NAME = "fake";
private String        TAG         = "PGGURU";
private static String celcius;
private static String fahren;
Button                b;
TextView              tv;
EditText              et;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //Celcius Edit Control
    et = (EditText) findViewById(R.id.editText1);
    //Fahrenheit Text control
    tv = (TextView) findViewById(R.id.tv_result);
    //Button to trigger web service invocation
    b = (Button) findViewById(R.id.button1);
    //Button Click Listener
    b.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            //Check if Celcius text control is not empty
            if (et.getText().length() != 0 && et.getText().toString() != "") {
                //Get the text control value
                celcius = et.getText().toString();
                //Create instance for AsyncCallWS
                AsyncCallWS task = new AsyncCallWS();
                //Call execute 
                task.execute();
                //If text control is empty
            } else {
                tv.setText("Please enter Celcius");
            }
        }
    });
}


public void getFahrenheit(String celsius) {
    //Create request
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    //Property which holds input parameters
    PropertyInfo celsiusPI = new PropertyInfo();
    //Set Name
    celsiusPI.setName("ticketCode");

    System.out.println(celcius);

    //Set Value
    celsiusPI.setValue(celsius);
    //Set dataType
    celsiusPI.setType(double.class);
    //Add the property to request object
    request.addProperty(celsiusPI);
    //Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    //Set output SOAP object
    envelope.setOutputSoapObject(request);
    //Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        //Invole web service
        androidHttpTransport.call(SOAP_ACTION, envelope);
        //Get the response
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        //Assign it to fahren static variable
        fahren = response.toString();

    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

0 个答案:

没有答案