title: WCF REST Service JSON Post data
body: <p>Looking for some guidance on a wcf 4 rest service which is based on the WCF REST Template 40(CS) extension in VS2010.  I've spent the last couple of days trying to get this bugger to work, reviewing other posts, and while I've gotten close, I can't seem to cross the finish line.  After much frustration, it is finally hitting the service and posting (using fiddler request builder) but the method parameter is coming across as null, but it's being set properly in the request builder.  I'm guessing that it may be a config issue at this point, but as the deadline looms, I'm running out of time for more research.  FWIW, in debugging, the jsonstring variable is null.  Self admittedly kind of a noob question as this is the first time through REST for me, any help would be much appreciated!</p>
  
  <p>Thanks in advance.</p>
  
  <p>web.config</p>
  
  <pre><code>&lt;system.web&gt;
    '&lt;compilation debug="true" targetFramework="4.0" /&gt;
  &lt;/system.web&gt;
  
  &lt;system.webServer&gt;
   &lt;modules runAllManagedModulesForAllRequests="true"&gt;
     &lt;add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
   &lt;/modules&gt;
  &lt;/system.webServer&gt;
  
  &lt;system.serviceModel&gt;
   &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
   &lt;standardEndpoints&gt;
     &lt;webHttpEndpoint&gt;
       &lt;standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/&gt;
     &lt;/webHttpEndpoint&gt;
   &lt;/standardEndpoints&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>global.asax.cs</p>
  
  <pre><code>   public class Global : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
           RegisterRoutes();
        }
  
        private void RegisterRoutes()
        {
           RouteTable.Routes.Add(new ServiceRoute("Scoring", new WebServiceHostFactory(), typeof(ScoringSvc)));
        }
     }
  </code></pre>
  
  <p>Service code</p>
  
  <pre><code>[ServiceContract]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
  public class ScoringSvc 
  {
     [OperationContract]
     [WebInvoke
        (Method = "POST",
        BodyStyle = WebMessageBodyStyle.WrappedRequest,
        RequestFormat=WebMessageFormat.Json,
        ResponseFormat=WebMessageFormat.Json)]
     public string BOB(string jsonstring)
     {
        return "Received: " + jsonstring;
     }
  }
  </code></pre>
  
  <p>Fiddler request header</p>
  
  <pre><code>Host: localhost
  Content-Length: 20
  Content-Type: application/json; charset=UTF-8
  </code></pre>
  
  <p>request body</p>
  
  <pre><code>{"Name":"Frank"}
  </code></pre>
  
  <p>Raw response from fiddler</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: private
  Content-Length: 12
  Content-Type: application/json; charset=utf-8
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Date: Mon, 21 Mar 2011 21:31:14 GMT
  
  "Received: "
  </code></pre>