I'm new to ksoap2 and I'm trying to get example w3 schools example working. For some reason it always fails on this line.
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
I dont know what is causing the fail. The android app just blows up. I have set internet permisions in Manifest. Im not really sure what is going on. Thanks
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.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;
public class WebServiceTurorialActivity extends Activity implements OnClickListener{
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
(findViewById(R.id.button1)).setOnClickListener(this);
}
public void onClick(View v) {
int a;
int b;
try
{
// EditText ed1=(EditText)findViewById(R.id.editText1);
// EditText ed2=(EditText)findViewById(R.id.editText2);
// a = Integer.parseInt(ed1.getText().toString());
// b = Integer.parseInt(ed2.getText().toString());
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
//Request.addProperty("a", a);
// Request.addProperty("b", b);
Request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE transport= new HttpTransportSE(URL);
transport.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
Toast.makeText(this,"200 " + resultString,Toast.LENGTH_SHORT).show();
}catch(Exception ex) {
Toast.makeText(this,"FALSE",Toast.LENGTH_SHORT).show();
}
}
}