【问题标题】:WCF: The client and service bindings may be mismatched?WCF:客户端和服务绑定可能不匹配?
【发布时间】:2015-02-09 17:08:08
【问题描述】:

尝试将 Mtom 消息编码与我的 WCF 服务一起使用,以尝试并加快从 SQL Server 传输大型查询结果的速度。

这是我的服务器端 WCF 配置:

 <service name="IsesService.IsesService">
    <endpoint address="" binding="basicHttpBinding" contract="IsesService.IIsesService" bindingConfiguration="basicHttp">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
      <dataContractSerializer maxItemsInObjectGraph="2147483646" />
      <!-- 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>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttp" messageEncoding="Mtom" allowCookies="true"
             maxReceivedMessageSize="2147483647"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647" >
      <readerQuotas maxDepth="32"
           maxArrayLength="2147483647"
           maxStringContentLength="2147483647"/>
    </binding>
  </basicHttpBinding>
</bindings>

还有我的客户端(WPF 应用)配置:

 <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttp" maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8080/" binding="basicHttpBinding"
            bindingConfiguration="basicHttp" contract="ServiceReference.IIsesService"
            name="BasicHttpBinding_IIsesService" />
    </client>
</system.serviceModel>

我得到客户端和服务绑定可能不匹配。...

【问题讨论】:

  • 可以在客户端添加messageEncoding="Mtom"吗?
  • 不,这是绑定的属性...

标签: c# wpf wcf


【解决方案1】:

你的绑定basicHttp的配置在服务端和客户端应该是一样的。您可以将服务配置中&lt;basicHttpBinding&gt;(包括 readerQuotas)之间的所有内容粘贴到客户端配置中以进行修复。

【讨论】:

  • 太棒了,让一切顺利。不幸的是,Motm 似乎并没有解决延迟问题......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-24
  • 2012-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-21
相关资源
最近更新 更多