문제

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;
        }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top