consuming webservice in android
-
30-05-2021 - |
문제
http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/ The above link taught me how to consume webservice in android its working properly,the problem is it just printing some text after loading.But i need to consume the webservices using buttons while clicking.Please let me know the codes or with some example codes.
Thanks for any help!
해결책
This has nothing to do with webservice consumption at all.
You need to implement OnClick on the button then have it call a function to runs that code.
private void consumeWS(){
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();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btnSubmit: consumeWS(); break;
}
}
제휴하지 않습니다 StackOverflow