IIS 7上托管的WCF服务的ServiceActivationException

时间:2011-06-27 08:31:27

标签: wcf iis-7

我们在IIS 7中托管了RESTful WCF服务。我们希望http和https都可以使用服务。所以我们为服务主机添加了2个绑定 -
HTTP ://service.abc.com
HTTPS ://service.abc.com

所有实施单一合同的服务都可以正常运行,但对于实施多个合同的任何服务,我们都会获得 System.ServiceModel.ServiceActivationException

只有一种类型的绑定 http https ,一切正常。

任何解决方案?

服务配置 -

<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>

2 个答案:

答案 0 :(得分:0)

我是wcf的新手,但是我已经在stackoverflow上读到了它,如果你的服务有多个合同,那么你必须为每个合同添加引用。如果有4个合同,那么必须创建4个服务参考

答案 1 :(得分:0)

您希望在服务上公开的每个合同都需要两个端点。一个端点用于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>