简体   繁体   English

IIS 7上托管的WCF服务的ServiceActivationException

[英]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. 我们在IIS 7中托管了RESTful WCF服务。我们希望该服务可用于http和https。 So we have added 2 bindings for service host- 因此,我们为服务主机添加了2个绑定-
http ://service.abc.com http://service.abc.com
https ://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. 所有实现单个合同的服务都可以正常工作,但是对于实现多个合同的任何服务,我们都会获得System.ServiceModel.ServiceActivationException

Everything works fine with only one type of binding either http or https . 只有一种绑定类型httphttps,一切都可以正常工作。

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. 我是wcf的新手,但是我已经在stackoverflow上阅读了它,如果您的服务有多个合同,则必须为每个合同添加参考。 if there are 4 contracts then 4 service reference has to be created 如果有4个合同,则必须创建4个服务参考

You need two endpoints for each contract you want to expose on the service. 您要在服务上公开的每个合同都需要两个端点。 One endpoint will be for HTTP and second for HTTPS: 一个端点用于HTTP,第二个端点用于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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM