title: Json web service - NULL as values
body: <p>I have a c# web service with the following definition:</p>
  
  <pre><code>    [WebInvoke(Method = "POST",
          ResponseFormat = WebMessageFormat.Json,
          RequestFormat = WebMessageFormat.Json,
          BodyStyle = WebMessageBodyStyle.Wrapped,
          UriTemplate = "BCryptLogin")]
      LoginResponse BCryptLogin(LoginData logindata);
  </code></pre>
  
  <p>And the actual function is</p>
  
  <pre><code>    public LoginResponse BCryptLogin(LoginData logindata)
      {
          string login = logindata.login;
          string password = logindata.password;
  
          // code be here
      }
  </code></pre>
  
  <p><strong>When trying to access the "logindata.login" I get a NullReferenceException:</strong></p>
  
  <pre><code>System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=LoginService
  StackTrace:
     at LoginService.LoginService.BCryptLogin(LoginData logindata) in C:\services\LoginService\LoginService\LoginService.svc.cs:line 74
     at SyncInvokeBCryptLogin(Object , Object[] , Object[] )
     at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
     at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
  </code></pre>
  
  <p>This is my first attempt at POST web service and I am fairly clueless :S What is going wrong?</p>
  
  <p>My testing request looks like this:</p>
  
  <pre><code>{"login":"username","password":"password"}
  </code></pre>
  
  <p>(also tried)</p>
  
  <pre><code>{"LoginData":{"login":"username","password":"password"}}
  </code></pre>
  
  <p>And the LoginData object is defined like this:</p>
  
  <pre><code>[DataContract]
  public class LoginData
  {
      [DataMember]
      public string login { get; set; }
      [DataMember]
      public string password { get; set; }
  }
  </code></pre>