Hi I am trying the android application connecting with web services from the following link
I am able to create xsdl file in web services This is the code in android
package com.example.androidwsdlfrontend;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidWSDLFrontEnd extends Activity {
private String METHOD_NAME = "sum"; // our webservice method name
private String NAMESPACE = "http://calculator.backend.web.org";//”"; // Here package name in webservice with reverse order.;
private String SOAP_ACTION = NAMESPACE + METHOD_NAME; // NAMESPACE + method name
private static final String URL = "http://10.0.2.2:8080/AndroidBackend/services/Calculate?wsdl";//”"; // you
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_wsdlfront_end);
TextView tv = (TextView) findViewById(R.id.txtAddition);
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("i", 5);
request.addProperty("j", 15);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Object result = envelope.getResponse();
System.out.println("Result: " + result.toString());
((TextView) findViewById(R.id.txtAddition)).setText("Addition: "+ result.toString());
} catch (Exception E) {
E.printStackTrace();
((TextView) findViewById(R.id.txtAddition)).setText("Error: "+ E.getClass().getName() + ":" + E.getMessage());
}
}
}
In the above code when I compile I am getting the error at
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
But I am not knowing how to resolve it. Please help me. I have mentioned my ipaddress at that particular position.