Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF service under https environment

Tags:

https

wcf

I've created and tested WCF service, everything works fine.

When I deployed to TEST environment and tried to open https://my.site/myapp/EnrollmentService.svc I've got the error message:

Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [https].

Internet showed me that I need to add some more configuration options:

http://www.codeproject.com/KB/WCF/7stepsWCF.aspx

I've added some settings to service web.config file. Now it looks like in the following way:

<system.serviceModel>
<services>
  <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
    <endpoint 
      address="https://my.site/myapp/EnrollmentService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="TransportSecurity"
      contract="McActivationApp.IEnrollmentService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="McActivationApp.EnrollmentServicBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

Actually, I've added "bindings" section and specified it for my endpoint.

But this changed nothing...

Please advise, what I need to do. Thanks a lot!

P.S. Are there any differences in WCF service consuming from https and http resources?

like image 470
Budda Avatar asked Jan 10 '11 21:01

Budda


People also ask

Is WCF secure?

WCF provides a secure, reliable, scalable messaging framework that can work over any protocol in any network. However, you need to secure your WCF service from phishing attacks when passing sensitive information through the network.

What is a WCF service?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.


1 Answers

When you want to expose your service only over HTTPS (site does not support HTTP at all) you can't use anything that is dependent on HTTP. Your current configuration exposes help page on HTTP and also mex endpoing (with wrong contract) on HTTP. So try this:

<system.serviceModel> 
  <services>   
    <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">     
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="McActivationApp.IEnrollmentService"/>     
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />   
    </service> 
  </services> 
  <behaviors>   
    <serviceBehaviors>     
      <behavior name="McActivationApp.EnrollmentServicBehavior">         
        <serviceMetadata httpsGetEnabled="True"/>       
        <serviceDebug includeExceptionDetailInFaults="False" />     
      </behavior>   
    </serviceBehaviors> 
  </behaviors> 
  <bindings>   
    <basicHttpBinding>     
      <binding name="TransportSecurity">       
        <security mode="Transport">         
          <transport clientCredentialType="None" />       
        </security>     
      </binding>   
    </basicHttpBinding> 
  </bindings> 
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />      
</system.serviceModel>
like image 108
Ladislav Mrnka Avatar answered Sep 21 '22 13:09

Ladislav Mrnka