title: HTTP 400 Bad Request when calling WCF Service Operation?
body: <p>When I call <a href="http://localhost/TestService.svc/GetColors" rel="noreferrer">http://localhost/TestService.svc/GetColors</a>, I get a Http (400) Bad Request.  When I run this in fiddler, I also get Bad Request.  When I invoke the service through the wcf test client, it works fine though.  What could cause this?</p>
  
  <p>Service contract:</p>
  
  <pre><code>[ServiceContract]
  public interface ITestService
  {
      [OperationContract]
      string GetColors();
  }
  </code></pre>
  
  <p>Implementation of ITestService:</p>
  
  <pre><code>[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
  public class TestService : ITestService
  {
      public List&lt;Color&gt; GetColors()
      {
          List&lt;Color&gt; colors= new List&lt;Color&gt;();
  
          colors.Add(new Color { Name = "Red", Code = "123" });
          colors.Add(new Color { Name = "Blue", Code = "323" });
          colors.Add(new Color { Name = "Green", Code = "3394" });
  
         return colors;
      }
  }
  </code></pre>
  
  <p>Here is my 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;bindings&gt;
           &lt;wsHttpBinding&gt;
              &lt;binding name="CustomAuthentication"&gt;
                 &lt;security mode="Message"&gt;
                    &lt;message clientCredentialType="UserName"/&gt;
                 &lt;/security&gt;
              &lt;/binding&gt;
           &lt;/wsHttpBinding&gt;
        &lt;/bindings&gt;
        &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
        &lt;services&gt;
            &lt;service name="TestService.TestService"
                  behaviorConfiguration="CustomValidator" &gt;
               &lt;endpoint 
                   address="" 
                   binding="wsHttpBinding" 
                   bindingConfiguration="CustomAuthentication"
                   contract="TestService.ITestService"&gt;
                   &lt;identity&gt;
                      &lt;dns value="localhost" /&gt;
                   &lt;/identity&gt;
               &lt;/endpoint&gt;
               &lt;endpoint 
                   address="mex" 
                   binding="mexHttpBinding" 
                   contract="IMetadataExchange" /&gt;
               &lt;host&gt;
                   &lt;baseAddresses&gt;
                       &lt;add baseAddress="http://localhost/TestService/" /&gt;
                   &lt;/baseAddresses&gt;
               &lt;/host&gt;
            &lt;/service&gt;
        &lt;/services&gt;
        &lt;behaviors&gt;
            &lt;serviceBehaviors&gt;
               &lt;behavior name="CustomValidator"&gt;
                  &lt;serviceCredentials&gt;
                     &lt;userNameAuthentication userNamePasswordValidationMode="Custom"
                                  customUserNamePasswordValidatorType="TestService.CustomUserNameValidator, TestService"/&gt;
                     &lt;serviceCertificate findValue="Test" storeLocation="LocalMachine" 
                           storeName="My" x509FindType="FindBySubjectName"/&gt;
                  &lt;/serviceCredentials&gt;
                  &lt;serviceMetadata httpGetEnabled="True"/&gt;
               &lt;/behavior&gt;
               &lt;behavior&gt;
                  &lt;serviceMetadata httpGetEnabled="True"/&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="False"/&gt;
               &lt;/behavior&gt;
           &lt;/serviceBehaviors&gt;
        &lt;/behaviors&gt;
     &lt;/system.serviceModel&gt;
     &lt;system.webServer&gt;
         &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
     &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>When I call it, I just open up a any browser and put the url <code>http://localhost/TestService.svc/GetColors</code>. If I do it through the dev environment, I see the Http 400 bad request. If I do it through IIS, I just see a blank page.</p>
  
  <p>Here is the InnerException:</p>
  
  <pre><code>&lt;ExceptionString&gt;System.Xml.XmlException: The body of the message cannot be read  
  because it is empty.&lt;/ExceptionString&gt;
  </code></pre>
  
  <p>Another question regarding my CustomUserNameValidation:</p>
  
  <p>I am implementing Custom Validation through the Validate Method of UserNamePasswordValidator, but when I call something like GetColors through the wcf client, it does not invoke the Validate method.  The only way I can get it to Invoke validate is if I call Validate(user,pass) directly in GetColors.  I thought it woulld be called automatically for every service call if you have it setup correctly in web.config.</p>