2013-05-29 21 views
1

以下是VS2012中新WCF服務應用程序的web.config的默認佈局。關於默認WCF項目web.config佈局的混淆

讓我感到困惑的是,它似乎不匹配任何在線示例或教程。沒有定義端點或綁定,但可以調用該服務。

我試圖增加MaxReceivedMessageSize屬性時遇到問題 - 我使用了它,並沒有線索在哪裏查看我的web.config。

有人能指出我爲什麼這麼奇怪的佈局正確的方向?

我期望它看起來更像This SO question about setting MaxReceivedMessageSize,甚至像Michelle Bustamante的WCF教程,這是我最初學習WCF的方式。

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</configuration> 

回答

3

從.NET 4.0開始,WCF引入了默認端點和綁定的概念,允許開發人員創建服務,而無需在配置文件中定義一堆東西。

發佈的配置文件是針對4.5,這就是爲什麼你看到這樣一個裸WCF配置。如果你需要增加你的maxMessageSize,你需要在配置中明確地定義它。

您可以通過設置做到這一點綁定定義爲默認值(由binding元素省略name屬性),或創建一個端點,並明確賦予您通過bindingConfig屬性定義的綁定配置。

請參閱A Developer's Introduction to Windows Communication Foundation 4

您還可以通過我查了以前的答案是有例子:https://stackoverflow.com/a/16099054/745969

+0

感謝蒂姆。我使用一些舊式手動聲明所有內容,並將其設置在那裏,工作得很好:) – NibblyPig