删除http绑定时继续获取System.ServiceModel.ServiceActivationException

时间:2016-06-08 14:48:13

标签: wcf https

我在Windows Server 2012上运行了基于WCF的web api。 我最近试图删除http,突然间我收到了System.ServiceModel.ServiceActivationException错误。如果我再添加http绑定,它会再次起作用。

如何修复它以便我只能在https上运行它?谢谢你的帮助!

<?xml version="1.0"?>
<configuration>
<appSettings>
  <add key="appveripad" value="xx"/>    
</appSettings>
<system.web>
  <compilation debug="true" targetFramework="4.0" />
  <httpRuntime maxRequestLength="2147483647" executionTimeout="3600" useFullyQualifiedRedirectUrl="true" />
  <customErrors mode="Off" />
</system.web>
<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <standardEndpoints>
    <webHttpEndpoint>
      <standardEndpoint name=""
                      transferMode="Buffered"
                      maxBufferSize="2147483647"
                      maxReceivedMessageSize="2147483647"
                      defaultOutgoingResponseFormat="Json"
                      helpEnabled="true"
                      automaticFormatSelectionEnabled="true">
      <readerQuotas maxDepth="64"
                    maxNameTableCharCount="2147483647"
                    maxStringContentLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxArrayLength="2147483647" />
    </standardEndpoint>
  </webHttpEndpoint>
</standardEndpoints>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <directoryBrowse enabled="true"/>
</system.webServer>

1 个答案:

答案 0 :(得分:0)

事实证明,WCF的web.conf结构发生了变化并且已经简化了很多。

我自己通过检查事件查看器/ Windows日志/应用程序中的确切Windows日志错误来修复它。

错误消息已写入

由于编译期间的异常,无法激活

。异常消息是:在配置中检测到端点引用周期。必须删除以下引用循环:webHttpEndpoint /,webHttpEndpoint /。 (C:\ inetpub \ wwwroot \ xxx \ web.config第111行)。 ---&GT; ...  进程名称:w3wp  流程ID:10396

然后我意识到我必须删除现在web.config文件中的冗余端点。

以下是启用了IIS中的https绑定的web.config的更正部分。使用和/或不使用http绑定,它可以工作。我唯一做的就是删除了端点,并添加了绑定部分。

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" />
    </binding>
    <binding name="SecureTransport" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>