title: Receiving POST data in WCF Service
body: <p>I read many tutorials but I could not get this running for my project. I made few GET services which send data and they work great, but I have problems receiving the data. I would really appreciate it if someone could tell me where I fail, instead of posting some links. :)
  When I try to call the service in my browser I get the error: Method not allowed. But I Think this is just the first error.</p>
  
  <p>Here is my code.
  First the code in Android where I call the service: </p>
  
  <pre><code>public class MainActivity extends Activity {
  
  String SERVICE_URI = "http://10.0.2.2:51602/RestServiceImpl.svc";
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      HttpPost request = new HttpPost(SERVICE_URI + "/registerUser");
      request.setHeader("Accept", "application/json");
      request.setHeader("Content-type", "application/json");
  
      try {
          JSONStringer user = new JSONStringer()
                  .object()
                  .key("userInfo")
                  .object()
                      .key("Email").value("mail")
                      .key("Password").value("pass")
                      .key("Cauntry").value("country")
                      .key("UserName").value("username")
                  .endObject()
          .endObject();
  
          StringEntity entity = new StringEntity(user.toString());
          request.setEntity(entity);
  
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpResponse response = httpClient.execute(request);
  
  
          } catch (JSONException e) {
              e.printStackTrace();
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>IRestServiceImpl.cs:</p>
  
  <pre><code>[ServiceContract]
  public interface IRestServiceImpl
  {
      [OperationContract]
      [WebInvoke(Method = "POST",
          UriTemplate = "registerUser",
          BodyStyle = WebMessageBodyStyle.Wrapped,
          ResponseFormat = WebMessageFormat.Json,
          RequestFormat = WebMessageFormat.Json)]
      void receiveData(String data);
  }
  </code></pre>
  
  <p>RestServiceImpl.cs:</p>
  
  <pre><code>public class RestServiceImpl : IRestServiceImpl
  {
      public void receiveData(String data)
      {
          //some code
      }
  }
  </code></pre>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"&gt;
  
          &lt;endpoint address ="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web"&gt;
  
          &lt;/endpoint&gt;
        &lt;/service&gt;
      &lt;/services&gt;
  
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="ServiceBehaviour"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="web"&gt;
            &lt;webHttp/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>