private static String SOAP_ACTION = "http://localhost:8080/MyFirstWebService/services/FirstWebService";
private static String NAMESPACE = "http://localhost:8080/MyFirstWebService/services/";
private static String METHOD_NAME = "addTwoNumbers";
private static String URL = "http://localhost:8080/MyFirstWebService/services/FirstWebService?wsdl";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("firstNumber",""+5);
request.addProperty("secondNumber",""+5);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// Make the soap call.
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
Log.d("prabhu","result is ....."+result);
if(result != null){
TextView t = (TextView)this.findViewById(R.id.resultbox);
Log.d("prabhu","result is ....."+result.getProperty(0).toString());
t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
}
}
Tuesday, November 13, 2012
Soap Web Service call in android
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment