title: WCF service using transport clientCredentialType Basic
body: <p>I'm trying to create a wcf service which does basic authentication, but i'm having some troubles.</p>
  
  <p>Here's what my web.config for the service looks like:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;client /&gt;
          &lt;services&gt;
              &lt;service name="Service.DataExchangeService" behaviorConfiguration="MyBehavior"&gt;
                  &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsDataImportEndpoint" contract="Service.IDataExchangeService"&gt;
                      &lt;identity&gt;
                          &lt;dns value="localhost" /&gt;
                      &lt;/identity&gt;
                  &lt;/endpoint&gt;
                  &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt;
                  &lt;host&gt;
                      &lt;baseAddresses&gt;
                          &lt;add baseAddress="http://localhost:8732/Design_Time_Addresses/DataExchange.Server.Service/Service1/" /&gt;
                      &lt;/baseAddresses&gt;
                  &lt;/host&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="wsDataImportEndpoint" maxBufferPoolSize="2147483647"
                      maxReceivedMessageSize="2147483647"&gt;
                      &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                          maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                      &lt;security mode="Transport"&gt;
                          &lt;transport clientCredentialType="Basic"/&gt;
                          &lt;message clientCredentialType="UserName" negotiateServiceCredential="true" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="MyBehavior"&gt;
                      &lt;serviceMetadata httpsGetEnabled="true" /&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
                      &lt;serviceCredentials&gt;
                          &lt;userNameAuthentication customUserNamePasswordValidatorType="DataExchange.Server.Service.UserNameValidator, DataExchange.Server.Service"
                                                  userNamePasswordValidationMode="Custom" /&gt;
                      &lt;/serviceCredentials&gt;
                  &lt;/behavior&gt;
                  &lt;behavior name=""&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;connectionStrings&gt;
          &lt;add name="ApplicationServices" connectionString="data source=sharept07\mssqlserver2008;initial catalog=VOS.Membership;integrated security=True;" providerName="System.Data.SqlClient" /&gt;
          &lt;add name="ROSEntities" connectionString="metadata=res://*/ROSModel.csdl|res://*/ROSModel.ssdl|res://*/ROSModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=sharept07\MSSQLServer2008;initial catalog=VOS;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
      &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and here's what my client config file looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="WSHttpBinding_IDataExchangeService" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                      allowCookies="false"&gt;
                      &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                      &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                          enabled="false" /&gt;
                      &lt;security mode="Transport"&gt;
                          &lt;transport clientCredentialType="Basic" proxyCredentialType="None"
                              realm="" /&gt;
                          &lt;message clientCredentialType="UserName" negotiateServiceCredential="true" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="https://server.com:446/DataExchangeService/DataExchangeService.svc"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDataExchangeService"
                  contract="DataExchangeSvc.IDataExchangeService" name="WSHttpBinding_IDataExchangeService"&gt;
                  &lt;identity&gt;
                      &lt;dns value="localhost" /&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and here's how i'm calling the service within my client:</p>
  
  <pre><code> static void Main(string[] args)
      {
          using (var client = new DataExchangeSvc.DataExchangeServiceClient())
          {
              client.ClientCredentials.UserName.UserName = "test";
              client.ClientCredentials.UserName.Password = "test";
              var data = client.RetrieveData();
          }
      }
  </code></pre>
  
  <p>When i set the the transport mode to "None" within security node in the Service config file the above works perfectly if i omit the credential lines, but the moment i change it to Basic i keep getting this error:</p>
  
  <pre><code>There was no endpoint listening at https://server.com:446/DataExchangeService/DataExchangeService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
  </code></pre>
  
  <p>I don't really know what's going on so if anyone can guide me in any way that would be extremely helpful.</p>
  
  <p>Thanks</p>