我无法理解这段代码是真是假:
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";
这是我的 Web 服务站点:http ://aspamng.jahanmir.ir/ 。如果我发送 13 到假元素,Web 服务应该响应。其实我明白了NAMESPACE
,SOAP_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();
}
}