开发者

Restful WCF (webhttpbinding) in IIS breaks after adding https binding

开发者 https://www.devze.com 2022-12-13 06:43 出处:网络
I have a WCF service hosted in IIS (7.0) which implements multiple service contracts and therefore defines multiple endpoints (one for each contract). It has been working fine but I have just added an

I have a WCF service hosted in IIS (7.0) which implements multiple service contracts and therefore defines multiple endpoints (one for each contract). It has been working fine but I have just added an https binding to the IIS web application and I am now getting an activation exception specifying that the service implements multiple contracts but no endpoints are defined in configuration when they actually are. I found this article which solves a similar problem caused by adding host names to IIS, but it doesn't seem to help my situation.

Here is a snippet of my configuration which is relevant:

<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.M开发者_如何学CidTierAccessService/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>

Any suggestions are appreciated.


If you are configuring HTTPS for the binding (say SecureRestBindingConfiguration), you also need to set "https" in the address of the the endpoints that you want to expose as https. e.g.

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

Keyword: https, SecureRestBindingConfiguration

UPDATE: Assumed you configured https transport within SecureRestBindingConfiguration.


you can refer this link.. This link helps to give secure with SSL. Before that you have to install the SSL certificate in your IIS [enter link description here][1]

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

0

精彩评论

暂无评论...
验证码 换一张
取 消