2016-06-08 17 views
0

我有一個基於WCF的Web API在Windows Server 2012 iis上運行。 和我最近試圖刪除HTTP,突然我得到System.ServiceModel.ServiceActivationException錯誤。如果我添加http綁定,它再次工作。當http綁定被刪除時,繼續得到System.ServiceModel.ServiceActivationException

我該如何解決這個問題才能在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> 

+0

將安全模式設置爲「傳輸」? – Tim

回答

0

事實證明,web.conf對WCF的結構已發生變化,被簡化了很多。

我已經通過檢查事件查看器/ Windows日誌/應用程序中確切的Windows日誌錯誤來修復它。

錯誤消息寫道

無法激活由於在編譯過程中的異常。異常消息是:在您的配置中檢測到端點引用週期。必須刪除以下引用週期:webHttpEndpoint /,webHttpEndpoint /。 (C:\ inetpub \ wwwroot \ xxx \ web.config第111行)。 ---> ... 進程名稱:W3WP 進程ID:10396

然後我意識到,我必須刪除我在web.config文件現在多餘的端點。

下面是在web.config中啓用了在IIS中進行https綁定的已更正部分。使用和/或不使用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> 
相關問題