http://code.google.com/p/ksoap2-android/ adresinden ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar dosyasını indirelim.
package cem.examples.webservicecall;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
final static String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
final static String METHOD_NAME = "CelsiusToFahrenheit";
final static String NAMESPACE = "http://tempuri.org/";
final static String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
// ---------------------------------------------------
tv = (TextView) findViewById(R.id.editText1);
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE aht = new HttpTransportSE(URL);
aht.call(SOAP_ACTION, soapEnvelope);
String result = "Sonuç: "+(SoapPrimitive) soapEnvelope.getResponse();
tv.setText("Sonuç: " + result);
}
}