关于默认WCF project web.config布局的混淆

关于默认WCF project web.config布局的混淆,wcf,Wcf,下面是VS2012中新WCF服务应用程序的web.config的默认布局 让我困惑的是,它似乎与任何在线示例或教程都不匹配。没有定义端点或绑定,但是可以调用服务 我在尝试增加MaxReceivedMessageSize属性时遇到了一个问题——我在谷歌上搜索了它,不知道该在我的web.config中查找什么 有人能告诉我为什么它的布局如此奇怪吗 我希望它看起来更像甚至像任何像Michelle Bustamante的WCF教程,这就是我最初学习WCF的方式 <?xml version="1.0

下面是VS2012中新WCF服务应用程序的web.config的默认布局

让我困惑的是,它似乎与任何在线示例或教程都不匹配。没有定义端点或绑定,但是可以调用服务

我在尝试增加MaxReceivedMessageSize属性时遇到了一个问题——我在谷歌上搜索了它,不知道该在我的web.config中查找什么

有人能告诉我为什么它的布局如此奇怪吗

我希望它看起来更像甚至像任何像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>

从.NET 4.0开始,WCF引入了默认端点和绑定的概念,允许开发人员创建服务,而无需在配置文件中定义大量内容

发布的配置文件的目标是4.5,这就是为什么您会看到这样一个裸体的WCF配置。如果需要增加
maxMessageSize
,则需要在配置中明确定义它

您可以通过将该绑定定义设置为默认值(通过省略
binding
元素上的
name
属性)或创建端点并显式分配通过
bindingConfig
属性定义的绑定配置来完成此操作


您也可以查看我之前的答案,其中有示例:

谢谢Tim。我使用一些旧样式手动声明了所有内容,并在其中进行了设置,效果很好:)