0

我在现有网站中创建了一个简单的 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
4

1 回答 1

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="..." />
于 2013-06-10T08:25:24.553 回答