通过soap的asmx web服务,我想在android中的json对象中响应

时间:2014-01-29 04:49:01

标签: android json web-services soap asmx

我通过soap调用.asmx Web服务,我想在android中的json对象中响应它是如何可能的。我的代码是:

Thread myThread = new Thread()
{
    @Override
    public void run()
    {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("email",s1);
        request.addProperty("password",s2);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        envelope.dotNet = true;
        try {
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapObject result = (SoapObject)envelope.bodyIn;
            if(result != null){
                et_unm.setText(result.getProperty(0).toString());
            } else
                Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
        }catch (Exception e){
            Log.v("LOGIN::","Exception--->"+e.toString());
            e.printStackTrace();
        }
    }
};
myThread.start();

1 个答案:

答案 0 :(得分:0)

请关注此帖,

您可以使用内置的apache类,如HttpClient,HttpGet,HttpPost等。本文将对此进行介绍。

  

How to Call ASMX Web service VIA JSON object in android Application