【问题标题】:ServiceActivationException for WCF service hosted on IIS 7IIS 7 上托管的 WCF 服务的 ServiceActivationException
【发布时间】:2011-06-27 08:31:26
【问题描述】:

我们在 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>

【问题讨论】:

  • 我仍然不明白为什么人们在没有发布错误消息的情况下询问他们遇到的错误。您还应该提供有关如何配置服务的更多详细信息。

标签: wcf iis-7


【解决方案1】:

我是 wcf 的新手,但我在 stackoverflow 上阅读过,如果您的服务有多个合同,那么您必须为每个合同添加参考。如果有 4 个合同,则必须创建 4 个服务引用

【讨论】:

  • 没有。您仍在添加单个引用,但您将获得 4 个代理。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    • 1970-01-01
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多