HTTPS on basicHttpBinding for WCF Service

53,280

You need to change:

<serviceMetadata httpGetEnabled="true" />

to:

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
Share:
53,280
LCJ
Author by

LCJ

.Net / C#/ SQL Server Developer Some of my posts listed below -- http://stackoverflow.com/questions/3618380/log4net-does-not-write-the-log-file/14682889#14682889 http://stackoverflow.com/questions/11549943/datetime-field-overflow-with-ibm-data-server-client-v9-7fp5/14215249#14215249 http://stackoverflow.com/questions/12420314/one-wcf-service-two-clients-one-client-does-not-work/12425653#12425653 http://stackoverflow.com/questions/18014392/select-sql-server-database-size/25452709#25452709 http://stackoverflow.com/questions/22589245/difference-between-mvc-5-project-and-web-api-project/25036611#25036611 http://stackoverflow.com/questions/4511346/wsdl-whats-the-difference-between-binding-and-porttype/15408410#15408410 http://stackoverflow.com/questions/7530725/unrecognized-attribute-targetframework-note-that-attribute-names-are-case-sen/18351068#18351068 http://stackoverflow.com/questions/9470013/do-not-use-abstract-base-class-in-design-but-in-modeling-analysis http://stackoverflow.com/questions/11578374/entity-framework-4-0-how-to-see-sql-statements-for-savechanges-method http://stackoverflow.com/questions/14486733/how-to-check-whether-postback-caused-by-a-dynamic-link-button

Updated on July 09, 2022

Comments

  • LCJ
    LCJ almost 2 years

    I am using IIS 7. HTTPS binding is enabled on it with port number 443. I have a WCF service as an application under the website. I am trying to introduce HTTPS security to service (with basicHttpBinding) based on http://msdn.microsoft.com/en-us/library/ms729700.aspx

    I am getting the following error – “The provided URI scheme 'https' is invalid; expected 'http'.”. When I checked the event log it has the stack trace as follows:

    Stack Trace :    at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)
    
    at System.ServiceModel.Channels.HttpChannelFactory.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)
    

    What is the change required to make it working on HTTPS with basicHttpBinding?

    Note: Certificate is created using "Create Self Signed Certificate" in IIS 7.

     <system.serviceModel>
    
      <behaviors>
    <serviceBehaviors>
      <behavior name="serviceFaultBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
      </behaviors>
    
      <services>
    <service name="Business.TV.Clearance.Services.ServiceHandler"
             behaviorConfiguration="serviceFaultBehavior">
      <endpoint address=""
                binding="basicHttpBinding"
                contract="Business.TV.Clearance.Services.IServiceHandler"
                bindingConfiguration="httpBinding">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </service>
    

      <bindings>
    <basicHttpBinding>
    
      <binding name="httpBinding"
               maxReceivedMessageSize="2000000"
               maxBufferSize="2000000">
    
        <security mode="Transport">
          <transport clientCredentialType="Windows" />
        </security>
    
    
        <readerQuotas maxDepth="2147483647"
                      maxStringContentLength="2147483647"
                      maxArrayLength="2147483647" />
      </binding>
    </basicHttpBinding>
      </bindings>
    
       <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    
       <extensions>
     <behaviorExtensions>
      <add name="serviceFaultBehavior"
    type="Business.TV.Clearance.Services.ServiceFaultBehaviorExtensionElement,Business.TV.Clearance.Services, Version=1.0.0.0, Culture=neutral"/>
    </behaviorExtensions>
      </extensions>
    
    </system.serviceModel>
    
  • LCJ
    LCJ over 12 years
    I added httpsGetEnabled="true". Still the same error is there
  • Andrey Marchuk
    Andrey Marchuk over 12 years
    it will allow to generate service reference, but it's not problem here yet
  • LCJ
    LCJ over 12 years
    clientCredentialType="UserName". Where do I define the user name of the service? Any reference document to take the complete application for this?
  • Rajesh
    Rajesh over 12 years
    You can change that from "Username" to "Windows". That depends on what type of client cerdentials you want to have for authentication