为什么app.config中的订单设置很重要

时间:2009-09-15 07:11:47

标签: .net wcf app-config

我遇到了WCF测试的问题,当我移到system.servicemodel的顶部时,问题就解决了。 我的问题是,为什么这很重要? .NET不通过字段名称读取XML吗?

 <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceTypeBehaviors">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <!-- Server-->
    <binding
      name="ws"
      transferMode="Streamed"
      messageEncoding="Mtom"
      maxReceivedMessageSize="10067108864"
      maxBufferSize="500000"
      maxBufferPoolSize="500000"
      receiveTimeout="10:00:00"
      sendTimeout="10:00:00"
      closeTimeout="10:00:00"
      openTimeout="10:00:00">
      <readerQuotas
        maxDepth="32"
        maxStringContentLength="2147483647"
        maxArrayLength="2147483647"
        maxBytesPerRead="4096"
        maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None"/>
      </security>
    </binding>

    <!-- Server -->
      <binding 
        name="FileTransferServicesBinding" 
        transferMode="Streamed" 
        messageEncoding="Mtom" 
        maxReceivedMessageSize="10067108864" 
        maxBufferSize="500000" 
        maxBufferPoolSize="500000">
        <readerQuotas 
          maxDepth="32" 
          maxStringContentLength="655360" 
          maxArrayLength="655360" 
          maxBytesPerRead="4096" 
          maxNameTableCharCount="16384" />
      </binding>

  </basicHttpBinding>
</bindings>

<!-- Server -->
<services>
  <service behaviorConfiguration="MyServiceTypeBehaviors" name="Namespace.Namespace">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="FileTransferServicesBinding" contract="Namespace.INamespaceSC" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8081/Namespace" />
      </baseAddresses>
    </host>
    <endpoint address="mex" binding="mexHttpBinding" contract="Namespace.INamespaceSC" />
  </service>
</services>

<!-- Behaviors field was here before, when it didn't work -->

<!-- Client -->
<client>
  <endpoint
    address="http://localhost:8081/Namespace"
    binding="basicHttpBinding"
    bindingConfiguration="ws"
    contract="Namespace.INamespaceSC"
   />
</client></system.serviceModel>

2 个答案:

答案 0 :(得分:0)

我认为订单不重要!我开发了很多WCF服务,从未见过这样的行为......

答案 1 :(得分:0)

订单仅在服务或端点配置方面很重要,而您没有命名要使用的配置。在这种情况下,WCF将使用最匹配的配置。

我认为移动行为部分没有任何理由会产生任何影响。我经常将它们放在靠近底部的地方。