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

前端 未结 1 1189
感动是毒
感动是毒 2021-01-21 15:39

I am developing an android application... and I want to pass the data to asmx webservice via json object and I want the response of web service

相关标签:
1条回答
  • 2021-01-21 15:56

    Instead of using kSOAP library, you can do it with built-in apache classes like HttpClient, HttpGet, HttpPost, etc.

    For example: You want to send below JSON object:

    {
       "email":"test@test.com",
       "password":"test"
    }
    

    then you can set your request object by using setEntity():

    final String body = String.format("{\"email\":\"%s\",\"password\":\"%s\"}", s1, s2);
    
    HttpClient client = new DefaultHttpClient();
    HttpPost postMethod = new HttpPost(webServiceUrl);
    postMethod.setEntity(new StringEntity(body, "utf-8"));
    
    0 讨论(0)
提交回复
热议问题