Get Json Response from a web service in android
<p>I have a problem that I have a url which returns a Json response when we send function name and authentication. But when we call the same it gives wrong result as {error: Invalid method}, I don't know how to resolve this problem, because the same functinality is running on iPhone. Please suggest me the right solution.</p>

<p><strong>Code:</strong></p>

<pre><code>public Login_Service(HttpPost post,String usr_Name,String pass)
    {
        this.post = post;
        this.usr_Name = usr_Name;
        this.pass = pass;
    }
    public String call_Service() throws ClientProtocolException, IOException
    {
          HttpClient client = new DefaultHttpClient();
          HttpConnectionParams.setConnectionTimeout(client.getParams(), 20000); //Timeout Limit
          HttpResponse response;

          post.setHeader("Content-type", "application/x-www-form-urlencoded");
          HttpParams params = new BasicHttpParams();
          params.setParameter("method", "user.login");
          params.setParameter("username", usr_Name);
          params.setParameter("password", pass);
          params.setParameter("key", "28ec5c4e579c4af702852cb1d5f3a139");

          post.setParams(params);
          response = client.execute(post);
          System.out.println("The request body:"+post.toString());
          status_code = response.getStatusLine().getStatusCode();
          System.out.println("The Response Code:"+response.getStatusLine().getStatusCode());

          BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
          String str=""; 

          String line = null; 
           while ((line = reader.readLine()) != null) { 
              str +=line; 

           }


         System.out.println(str);
         return str;
    }
</code></pre>

<p><strong>And Calling from:</strong></p>

<pre><code>HttpPost post = new HttpPost("http://192.168.0.9/PROJECTS/VERSIONED/ShipFace/trunk/services/json");
                    final Login_Service obj = new Login_Service(post, ed_UsrName.getText().toString(), ed_pass.getText().toString());
                    String str;
                    try {
                        str = obj.call_Service();
                        System.out.println("The Json Response:"+str);
                    } catch (ClientProtocolException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
</code></pre>
