title: Setting up WCF Transport and Message Security
body: <p>I am trying to setup Transport and Message Security with a WCF Service.</p>
  
  <p>I have installed a local SSL certificate. But I am getting this error:</p>
  
  <pre><code>Error: Cannot obtain Metadata from http://localhost:57458/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error    URI: http://localhost:57458/Service1.svc    Metadata contains a reference that cannot be resolved: 'http://localhost:57458/Service1.svc'.    The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error    URI: http://localhost:57458/Service1.svc    There was an error downloading 'http://localhost:57458/Service1.svc'.    The request failed with the error message:--&lt;html&gt;    &lt;head&gt;        &lt;title&gt;Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].&lt;/title&gt;        &lt;style&gt;         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}          p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }         pre {font-family:"Lucida Console";font-size: .9em}         .marker {font-weight: bold; color: black;text-decoration: none;}         .version {color: gray;}         .error {margin-bottom: 10px;}         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }        &lt;/style&gt;    &lt;/head&gt;    &lt;body bgcolor="white"&gt;            &lt;span&gt;&lt;H1&gt;Server Error in '/' Application.&lt;hr width=100% size=1 color=silver&gt;&lt;/H1&gt;            &lt;h2&gt; &lt;i&gt;Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].&lt;/i&gt; &lt;/h2&gt;&lt;/span&gt;            &lt;font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "&gt;            &lt;b&gt; Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.            &lt;br&gt;&lt;br&gt;            &lt;b&gt; Exception Details: &lt;/b&gt;System.InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].&lt;br&gt;&lt;br&gt;            &lt;b&gt;Source Error:&lt;/b&gt; &lt;br&gt;&lt;br&gt;            &lt;table width=100% bgcolor="#ffffcc"&gt;               &lt;tr&gt;                  &lt;td&gt;                      &lt;code&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.&lt;/code&gt;                  &lt;/td&gt;               &lt;/tr&gt;            &lt;/table&gt;            &lt;br&gt;            &lt;b&gt;Stack Trace:&lt;/b&gt; &lt;br&gt;&lt;br&gt;            &lt;table width=100% bgcolor="#ffffcc"&gt;               &lt;tr&gt;                  &lt;td&gt;                      &lt;code&gt;&lt;pre&gt;[InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].]   System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +12298460   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +12295813   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67   System.ServiceModel.ServiceHostBase.ApplyConfiguration() +108   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192   System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +422   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]..]   System.Runtime.AsyncResult.End(IAsyncResult result) +687598   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75&lt;/pre&gt;&lt;/code&gt;                  &lt;/td&gt;               &lt;/tr&gt;            &lt;/table&gt;            &lt;br&gt;            &lt;hr width=100% size=1 color=silver&gt;            &lt;b&gt;Version Information:&lt;/b&gt;ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1            &lt;/font&gt;    &lt;/body&gt;&lt;/html&gt;&lt;!-- [InvalidOperationException]: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].   at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses)   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)[ServiceActivationException]: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]..   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService)   at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)--&gt;--.
  </code></pre>
  
  <p>Important part of the error is probably:</p>
  
  <pre><code>Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].
  </code></pre>
  
  <p>This is my web.config file:</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="Binding1"&gt;
            &lt;security mode="TransportWithMessageCredential"&gt;
              &lt;message clientCredentialType="UserName"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
  
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService"&gt;
          &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1"
            contract="AutoSenderWCFService.IService1"&gt;&lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt;
  
        &lt;/service&gt;
      &lt;/services&gt;
  
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="ServiceBehavior"&gt;
            &lt;serviceCredentials&gt;
  
              &lt;userNameAuthentication userNamePasswordValidationMode="Custom"
                customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/&gt;
              &lt;serviceCertificate findValue="Michael-PC.pth.local" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /&gt;
            &lt;/serviceCredentials&gt;
  
            &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
            &lt;serviceMetadata httpsGetEnabled="true" httpGetEnabled="True"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
    &lt;/system.serviceModel&gt;
   &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I want to create it so that I can debug it on my local computer and then upload it to my server and run it using a self certified certificate.. </p>