移至https =无法找到与scheme匹配的基址

时间:2013-06-10 08:16:40

标签: wcf

我在现有网站上创建了一个简单的WCF服务。我测试了它,一切似乎都很好。我现在已经使网站需要https但现在当我通过浏览器(或任何客户端)访问svc时,我得到了 -

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

Stack trace is as follows:
[InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding. Registered base address schemes are [http].]
   System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +12907656
   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost) +12905313
   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +69
   System.ServiceModel.ServiceHostBase.ApplyConfiguration() +178
   Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHost.ApplyConfiguration() +46
   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +184
   System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +46
   System.ServiceModel.ServiceHost.InitializeDescription(Object singletonInstance, UriSchemeKeyedCollection baseAddresses) +43
   System.ServiceModel.ServiceHost..ctor(Object singletonInstance, Uri[] baseAddresses) +247
   Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHost..ctor(WSTrustServiceContract serviceContract, Uri[] baseAddresses) +72
   Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHost..ctor(SecurityTokenServiceConfiguration securityTokenServiceConfiguration, Uri[] baseAddresses) +70
   Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +280
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1434
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598

1 个答案:

答案 0 :(得分:0)

您需要更改服务的配置,以便使用启用HTTPS的绑定。您可以查看此博文:http://weblogs.asp.net/srkirkland/archive/2008/02/20/wcf-bindings-needed-for-https.aspx

建议的解决方案是在web.config / app.config中定义自定义绑定,并将其安全模式设置为Transport

<bindings>
   <webHttpBinding>
     <binding name="webBinding">
       <security mode="Transport" />
     </binding>
   </webHttpBinding>
</bindings>

然后在端点的绑定配置中使用此绑定:

<endpoint address="" behaviorConfiguration="..." binding="webHttpBinding" bindingConfiguration="webBinding" contract="..." />