title: wcf wshttpbinding with username and password validator ProtocolException+XmlException
body: <p>i have a wcf service with this config at server side :</p>
  
  <pre><code>WSHttpBinding wshttp = new WSHttpBinding(SecurityMode.Message);
  wshttp.ReceiveTimeout = new TimeSpan(0, 30, 0);
  wshttp.MaxBufferPoolSize = 2147483647;
  wshttp.MaxReceivedMessageSize = 2147483647;
  
  wshttp.ReaderQuotas.MaxArrayLength = 2147483647;
  wshttp.ReaderQuotas.MaxBytesPerRead = 2147483647;
  wshttp.ReaderQuotas.MaxDepth = 2147483647;
  wshttp.ReaderQuotas.MaxNameTableCharCount = 2147483647;
  wshttp.ReaderQuotas.MaxStringContentLength = 2147483647;
  
  wshttp.Security.Message.AlgorithmSuite = 
      System.ServiceModel.Security.SecurityAlgorithmSuite.Basic256Sha256Rsa15;
  wshttp.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
  CustomBinding cb = new CustomBinding(wshttp);
  var clockSkew = new TimeSpan(2, 0, 0);
  SymmetricSecurityBindingElement security = 
      cb.Elements.Find&lt;SymmetricSecurityBindingElement&gt;();
  security.LocalClientSettings.MaxClockSkew = clockSkew;
  security.LocalServiceSettings.MaxClockSkew = clockSkew;
  
  // Get the 
  // System.ServiceModel.Security.Tokens
  //    .SecureConversationSecurityTokenParameters 
  SecureConversationSecurityTokenParameters secureTokenParams = 
      (SecureConversationSecurityTokenParameters)
          security.ProtectionTokenParameters;
  
  // From the collection, get the bootstrap element.
  SecurityBindingElement bootstrap = 
      secureTokenParams.BootstrapSecurityBindingElement;
  
  // Set the MaxClockSkew on the bootstrap element.
  bootstrap.LocalClientSettings.MaxClockSkew = clockSkew;
  bootstrap.LocalServiceSettings.MaxClockSkew = clockSkew;
  
  EndpointAddress ea = 
      new EndpointAddress(
          new Uri("http://localhost:80/MyService"), 
          System.ServiceModel.EndpointIdentity.CreateDnsIdentity(
                                          "MyService Certeficate"));
  
  isarService.AddServiceEndpoint(
          typeof(ServiceLayer.IService),
          cb, 
          new Uri("http://localhost:80/MyService")).Address = ea;
  
  
  isarService.Open();
  </code></pre>
  
  <p>and half of config is in app file like this :</p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;bindings /&gt;
      &lt;client /&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="ServiceBehavior" name="SL.Service"&gt;
          &lt;endpoint address="mex" binding="
                    mexHttpBinding" 
                    bindingConfiguration=""
            name="MexHttpEndPoint" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:80/MyService" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="ServiceBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
            &lt;serviceThrottling maxConcurrentCalls="100" 
                               maxConcurrentInstances="100" /&gt;
            &lt;serviceCredentials&gt;
              &lt;clientCertificate&gt;
                &lt;authentication customCertificateValidatorType="" 
                                certificateValidationMode="ChainTrust" /&gt;
              &lt;/clientCertificate&gt;
              &lt;serviceCertificate findValue="MyService Certeficate" 
                                  storeLocation="CurrentUser"
                storeName="Root" x509FindType="FindByIssuerName" /&gt;
              &lt;userNameAuthentication 
                  userNamePasswordValidationMode="Custom"
                  customUserNamePasswordValidatorType="ServiceLayer.CUAPValidator,ServiceLayer" /&gt;
            &lt;/serviceCredentials&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>i log my client error and they send log file to me for fix their app.application work for lots of my clients but some of them have this error :</p>
  
  <p><strong>System.ServiceModel.ProtocolException</strong> -> There is a problem with the XML that was received from the network. See inner exception for more details.</p>
  
  <p><strong>System.Xml.XmlException</strong> -> The data at the root level is invalid. Line 1, position 1.</p>
  
  <p>i do not know when 99 client work well with this config why 3 of them has this problem !</p>
  
  <p><strong>Question :</strong></p>
  
  <p>please help me for fix this issue with easiest way.</p>
  
  <p><strong>information :</strong></p>
  
  <p>i host my service with windows service .</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>I Log Error Exact With svc log on client side . then i read error and error was that. in server side i do not see error in log . i do not what is exact different but seems the different is internet connection i mean proxy server or vpn etc .</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>Can this happen for .net version ?? because the version 4 has some update on it .</p>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>see this error its same with other perhaps help</p>
  
  <p>The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
  Error Message
  
  A {
      FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #005a80; FONT-FAMILY: tahoma
  }
  A:hover {
      FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #0d3372; FONT-FAMILY: tahoma
  }
  TD {
      FONT-SIZE: 8pt; FONT-FAMILY: tahoma
  }
  TD.titleBorder {
      BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 0px solid; COLOR: #955319; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left
  }
  TD.titleBorder_x {
      BORDER-RIGHT: #955319 0px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 1px solid; COLOR: #978c79; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGR'.</p>
  
  <p>AND Inner Error :</p>
  
  <p>The remote server returned an error: (500) Internal Server Error.</p>