Professional Documents
Culture Documents
https://code.google.com/p/ksoap2-android/source/browse/m2-repo/com/google/code/ksoap2-
android/ksoap2-android-assembly/2.6.0?r=803
7. M file layout thit k giao din c 2 TextView lm nhn, 1 EditText nhp F, 1 EditText nhp C, 1
button i C sang F , 1 button i F sang C v 1 button Xa:
8. Truy cp a ch http://www.w3schools.com/webservices/tempconvert.asmx nhn vo hm u tin
(CelsiusToFahrenheit) ko xung bn di v phn tch c php.
Cho CelsiusToFahrenheit:
1. SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
2. NAMESPACE = "http://tempuri.org/";
3. METHOD_NAME = "CelsiusToFahrenheit";
4. URL = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
Cho FahrenheitToCelsius:
1. SOAP_ACTION = "http://tempuri.org/FahrenheitToCelsius";
2. NAMESPACE = "http://tempuri.org/";
3. METHOD_NAME = " FahrenheitToCelsius ";
4. URL = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
9. M file manifest v khai bo quyn internet
<uses-permission android:name="android.permission.INTERNET"/>
EditText etdoC,etdoF;
Button btFtoC, btCtoF,btclear;
13. Tip theo khai bo Transport v a vo URL. Sau gi hm call gi service v truyn vo action v
envelope.
//goi webservice
try {
httptransport.call( SOAP_ACTION1, envelope);
} catch (Exception e) {
Log.d("loi"," "+ e.toString());
}
//lay du lieu
SoapObject ketqua=(SoapObject)envelope.bodyIn;
if(ketqua!=null)
{
etdoC.setText(ketqua.getProperty(0).toString());
}
else
{
Toast.makeText(getApplicationContext(), "khong co ket qua",
Toast.LENGTH_SHORT).show();
}
15. Chy chng trnh (nh phi c internet). Nhp vo 1 con s F, nhn nt i F sang C thy kt qu.