title: calling the wcf service POST from the android
body: <p>my url is 
  <a href="http://example.com/WcfService/MasterService.svc" rel="nofollow">http://example.com/WcfService/MasterService.svc</a></p>
  
  <p>method name is "SearchOrganizations";</p>
  
  <p>String url = URL1 + "/" + METHOD_NAME_SEARCH_ORGANIZATION + "/";</p>
  
  <p>so my url will be <strong><a href="http://example.com/WcfService/MasterService.svc/SearchOrganizations/" rel="nofollow">http://example.com/WcfService/MasterService.svc/SearchOrganizations/</a></strong></p>
  
  <p>service type is POST. here is my code to call this service from android</p>
  
  <pre><code>JSONObject jsonObjSend = new JSONObject();
          try {
              jsonObjSend.put("data", params[0]);
              jsonObjSend.put("CurrentUserId", params[1]);
          } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          List&lt;NameValuePair&gt; paramswithkey = new ArrayList&lt;NameValuePair&gt;();
          paramswithkey.add(new BasicNameValuePair("data", params[0]));
          paramswithkey
                  .add(new BasicNameValuePair("CurrentUserId", params[1]));
          HttpClient client = new DefaultHttpClient();
          HttpPost httpPostRequest = new HttpPost(url);
  
          // httpPostRequest.setHeader("Accept", "application/soap+xml");
          httpPostRequest.setHeader("Content-Type",
                  "application/x-www-form-urlencoded; charset=utf-8");
          UrlEncodedFormEntity se = null;
          try {
              // se = new StringEntity(jsonObjSend.toString());
              se = new UrlEncodedFormEntity(/*
                                           * jsonObjSend.toString().getBytes(
                                           * "UTF8")
                                           */paramswithkey);
          } catch (UnsupportedEncodingException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          httpPostRequest.setEntity(se);
          HttpResponse response = null;
          try {
              response = client.execute(httpPostRequest);
          } catch (ClientProtocolException e) {
              Toast.makeText(getApplicationContext(),
                      "Please check your internet connection",
                      Toast.LENGTH_SHORT).show();
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          logI("BEFOR response METHOD_NAME_SEARCH_ORGANIZATION :" + response);
          BasicResponseHandler responseHandler = new BasicResponseHandler();
          String strResponse = null;
          if (response != null) {
              try {
                  strResponse = responseHandler.handleResponse(response);
              } catch (HttpResponseException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          logI("AFTER response METHOD_NAME_SEARCH_ORGANIZATION :"
                  + strResponse);
  </code></pre>
  
  <p>I have used this code using the JsonObject as well as NameValuePair but i am getting the exception of following</p>
  
  <pre><code> org.apache.http.client.HttpResponseException: Cannot process the message because the content type 'application/x-www-form-urlencoded; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.
  </code></pre>
  
  <p>.Net side they have called the service using the <strong>x-www-form-urlencoded</strong> but i am getting the expected type should be <strong>text/xml; charset=utf-8</strong></p>
  
  <p>How could i manage to call the POST service.
  I have tried with the different ways to call this service but failed to get the response</p>
  
  <p><a href="http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/" rel="nofollow">http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/</a></p>
  
  <p>but i couldn't be able to get the response.</p>