IIS中的Restful WCF(webhttpbinding)在添加https绑定后中断

时间:2009-11-30 00:07:48

标签: wcf iis binding https

我有一个在IIS(7.0)中托管的WCF服务,它实现了多个服务合同,因此定义了多个端点(每个合同一个端点)。它一直工作正常,但我刚刚添加了一个https绑定到IIS Web应用程序,我现在得到一个激活异常,指定该服务实现多个合同,但实际上没有在配置中定义端点。我发现this文章解决了因为向IIS添加主机名而导致的类似问题,但它似乎对我的情况没有帮助。

以下是我的配置的相关摘录:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="http://localhost/CDC.WebPortal.MidTierAccessService/"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>


<services>
  <service name="CDC.WebPortal.MidTier.MidTierAccessService"
           behaviorConfiguration="MidTierServiceBehaviour" >

    <endpoint address="http://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc"
              binding="webHttpBinding" bindingName="RestBindingConfiguration"
              contract="CDC.WebPortal.ServiceContract.IProductService"/>

    <endpoint address="http://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc/Category" binding="webHttpBinding" 
              bindingName="RestBindingConfiguration"
              contract="CDC.WebPortal.ServiceContract.ICategoryService"/>

    <endpoint address="http://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc/Account" binding="webHttpBinding" 
              bindingName="RestBindingConfiguration"
              contract="CDC.WebPortal.ServiceContract.IAccountService"/>

    <endpoint address="http://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc/Order"
              binding="webHttpBinding" bindingName="RestBindingConfiguration"
              contract="CDC.WebPortal.ServiceContract.IOrderService"/>

    <endpoint address="http://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc/mex"
              binding="mexHttpBinding" contract="IMetadataExchange" />

  </service>
</services>

任何建议都表示赞赏。

2 个答案:

答案 0 :(得分:1)

如果要为绑定配置HTTPS(例如SecureRestBindingConfiguration),则还需要在要公开为https的端点的地址中设置“https”。 e.g。

<endpoint address="https://localhost/CDC.WebPortal.MidTierAccessService/MidTierAccessService.svc"
                  binding="webHttpBinding" bindingName="SecureRestBindingConfiguration"
                  contract="CDC.WebPortal.ServiceContract.IProductService"/>

关键字:https,SecureRestBindingConfiguration

更新: 假设您在SecureRestBindingConfiguration中配置了https传输。

答案 1 :(得分:-1)

您可以参考此链接。此链接有助于通过SSL提供安全保障。 在此之前,您必须在IIS中安装SSL证书 [在此输入链接描述] [1]

[1]:http://taciturndiscourse.com/services/ssl-for-webhttpbinding/