开发者

ServiceActivationException for WCF service hosted on IIS 7

We have RESTful WCF service hosted in IIS 7. We want service to be available for both http and https. So we have added 2 bindings for service host-

http://service.abc.com

https://service.abc.com

All services implementing single contract work well, but we get System.ServiceModel.ServiceActivationException for any service which implements more than one contracts.

Everything works fine with only one type of binding either开发者_开发知识库 http or https.

Any solution?

service configuration -

<services>
<service behaviorConfiguration="RESTServiceBehavior" name="App.Services.Service1">
    <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="App.Contract.Services.IService1"                            bindingConfiguration="RESTServiceBinding"></endpoint>
</service>
</services>

<behaviors>
<endpointBehaviors>
    <behavior name="webBehavior">
        <webHttp/>
        <restGlobalErrorHandler/>
    </behavior>
</endpointBehaviors>

<serviceBehaviors>
    <behavior name="RESTServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
        <serviceAuthorization serviceAuthorizationManagerType="App.Services.AuthorizationManager, App.Services" />
    </behavior>
    <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
</serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>

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


i am new to wcf but i have read it on stackoverflow that if your service have several contracts then you have to add reference for each contract. if there are 4 contracts then 4 service reference has to be created


You need two endpoints for each contract you want to expose on the service. One endpoint will be for HTTP and second for HTTPS:

<service behaviorConfiguration="RESTServiceBehavior" name="App.Services.Service1">
    <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" 
              bindingConfiguration="RESTServiceBinding" contract="App.Contract.Services.IService1" />
    <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" 
              contract="App.Contract.Services.IService1" />
</service>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜