wcf奇怪的行为

时间:2013-03-21 05:01:16

标签: c# wcf formatting

<system.serviceModel>
  <services>
    <service name="Coevery.Services.Document.DocumentService" 
             behaviorConfiguration="aaa">
      <endpoint address="" 
                binding="basicHttpBinding" 
                bindingConfiguration="documentbinding" 
                contract="Coevery.Services.Document.IDocumentService">
      </endpoint>
    </service>
  </services>
  <bindings>
    <basicHttpBinding>
      <binding maxBufferPoolSize="2147483647" 
               maxReceivedMessageSize="2147483647" 
               allowCookies="true">
        <security mode="None">
        </security>
        <readerQuotas maxArrayLength="2147483647" 
                      maxNameTableCharCount="2147483647"
                      maxStringContentLength="2147483647" 
                      maxDepth="2147483647" 
                      maxBytesPerRead="2147483647" />
      </binding>
      <binding name="documentbinding" 
               closeTimeout="04:01:00" 
               openTimeout="04:01:00" 
               receiveTimeout="04:10:00" 
               sendTimeout="04:01:00" 
               allowCookies="false" 
               bypassProxyOnLocal="false" 
               hostNameComparisonMode="StrongWildcard" 
               maxBufferSize="2147483647" 
               maxBufferPoolSize="2147483647" 
               maxReceivedMessageSize="2147483647" 
               messageEncoding="Mtom" 
               textEncoding="utf-8" 
               useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" 
                      maxStringContentLength="2147483647" 
                      maxArrayLength="2147483647" 
                      maxBytesPerRead="2147483647" 
                      maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="aaa">
        <serviceSecurityAudit auditLogLocation="Application" 
                              serviceAuthorizationAuditLevel="Failure"
                              messageAuthenticationAuditLevel="Failure" 
                              suppressAuditFailure="true" />
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
        <serviceMetadata httpGetEnabled="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="true" />
        <serviceCredentials>
          <serviceCertificate findValue="WCfServer" 
                              storeLocation="LocalMachine" 
                              storeName="TrustedPeople"
                              x509FindType="FindBySubjectName"/>
        </serviceCredentials>
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="True" />
</system.serviceModel>

如果行为名称=“aaa”=&gt;目前已禁用此服务的元数据发布。 但没有名字,那就没关系。

有谁知道这有什么问题?我每次使用wcf都迷路了:D

1 个答案:

答案 0 :(得分:1)

这是WCF 4的功能。当您省略名称时,WCF服务会将其视为默认行为。见http://msdn.microsoft.com/en-us/library/ee354381.aspx

  

在WCF 3.x中,您必须定义您的命名行为配置   明确适用于服务和端点   “behaviorConfiguration”属性。使用WCF 4,您可以定义默认值   通过省略配置中的名称来进行行为配置   定义。如果将这些默认行为添加到machine.config,   它们将适用于机器上托管的所有服务或端点。