MaxReceivedMessageSize不适用于命名bindingConfiguration [英] MaxReceivedMessageSize does not work with named bindingConfiguration

查看:56
本文介绍了MaxReceivedMessageSize不适用于命名bindingConfiguration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正面临有关我的WCF流媒体服务的配置问题。我有一个自助托管3个WCF服务的Windows服务,其中一个服务使用Streams处理二进制内容的上传和下载。关于你必须将 maxReceivedMessageSize 设置为适当高的数字(例如2147483647)以便能够接收更大消息的文档,这就是我们所做的。



服务配置:



  <   service     name   =  DocumentService    behaviorConfiguration   =  DatashopServiceBehavior >  
< endpoint 合同 = IDocumentS服务 地址 = DocumentService

< span class =code-attribute> binding = basicHttpBinding name = basicHttpBinding bindingConfiguration =

< span class =code-attribute> behaviorConfiguration = DatashopServiceEndpointBehavior / >
< 端点 地址 = mex binding = mexHttpBinding 合同 = IMetadataExchange / >
< host < span class =code-keyword>>
< baseAddresses >
< add baseAddress = http:// localhost:8080 / Datashop / Documents / / >
< / baseAddresses >
< / host >
&l t; / service >





绑定配置:



 <   basicHttpBinding  >  
< ; binding name < span class =code-keyword> = transferMode = 流式 maxReceivedMessageSize = 2147483647 maxBufferSize = 2147483647 maxBufferPoolSize = 2147483647 >
< readerQuotas maxDepth = 2147483647 maxStringContentLength = 2147483647

< span class =code-attribute> maxArrayLength = 2147483647 maxBytesPerRead = 2147483647

< span class =code-attribute> maxNameTableCh arCount = 2147483647 / >
< / binding >
< / basicHttpBinding >





您会注意到端点的bindingConfiguration属性有一个空字符串值,绑定本身的name属性有一个空字符串。那是因为这是我们让它发挥作用的唯一方式。如果我们显式地命名绑定并使用该名称从端点引用它,就好像从未设置maxReceivedMessageSize属性并且大型二进制内容在WCF服务跟踪查看器中给出以下错误:



已超出传入邮件的最大邮件大小限额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。



我的同事隔离了流服务并检查了配置运行时使用反射,并发现maxReceivedMessageSize设置正确,但不知何故未应用。



虽然我们可以通过命名和引用来解决当前问题使用emtpy字符串的绑定配置,它不能解决根本问题,并且意味着如果我们想在同一服务上设置不同的端点但使用不同的绑定,我们就不能。



进一步信息:EndpointBehavior是WCFExtras以展平WSDL而我们没有使用服务客户端,而是使用 ChannelFactory< T>



之前有没有人遇到过这个问题,解决方案是什么?



我们将非常感谢任何帮助。

解决方案

问题在于我们是通过主机服务自助托管服务:



host.AddDefaultEndpoints();



我们用baseAddress愚蠢地调用服务:



http:// localhost:8080 / Datashop / Documents /



而不是:



http:// localhost:8080 / Datashop / Documents / DocumentService /



我还是不明白为什么当服务器端为bindingConfiguration名称有空字符串时该死的东西工作,但在这个阶段我不在乎。我更关心大量的啤酒,我要倒在脖子上,试着忘记过去两天追逐配置问题,认为这是WCF中的一个错误;)


 <   bindings  > ;  
< basichttpbinding >
< binding 名称 = FlightInventory_basicHttpBinding closetimeout = 00:20:00 opentimeout = 00:20:00 >
receiveTimeout =00:20:00sendTimeout =00:20:00allowCookies =false
bypassProxyOnLocal =falsehostNameComparisonMode =StrongWildcard
maxBufferPoolSize =2147483647maxBufferSize =2147483647maxReceivedMessageSize =2147483647
textEncoding =utf-8transferMode =BuffereduseDefaultWebProxy =true
messageEncoding =Text>
< readerquotas < span class =code-attribute> maxdepth = 2147483647 maxstringcontentlength = 2147483647 >
maxArrayLength =2147483647maxBytesPerRead =2147483647maxNameTableCharCount =2147483647/>
< security < span class =code-attribute> mode = >
< transport clientcredentialtype = proxycredentialtype = >
realm =/>
< 消息 < span class =code-attribute> clientcredentialtype = UserName algorithmsuite = 默认 / >
< / transport > < / security >
< / readerquotas > < / binding >
< / basichttpbinding >
< / bindings >
< ; 服务 >
< service name = FlightInventoryService.FlightInventory behaviorconfiguration = FlightInventoryService.ServiceBehaviour >
< 端点 地址 = binding = basicHttpBinding bindingconfiguration = FlightInventory_basicHttpBinding 合同 = FlightInventoryService.IFlightInventory >
< identity >
< dns value = localhost / >
< / identity >
< span class =code-keyword>< / endpoint >
< endpoint 地址 = mex binding = mexHttpBinding 合同 = IMetadataExchange / >
< / service >
< ; / services >
< 行为 >
< servicebehaviors >
< 行为 名称 = FlightInventoryService.ServiceBehaviour >
<! - 为避免泄露元数据信息,请将以下值设置为false并在部署之前删除上面的元数据端点 - >
< servicemetadata httpgetenabled = true / >
<! - 要接收故障中的异常详细信息以进行调试,请将以下值设置为true。在部署之前设置为false以避免泄露异常信息 - >
< servicedebug includeexceptiondetailinfaults = true / >
< datacontractserializer maxitemsinobjectgraph = 2147483647 / >
< / behavior >
< / servicebehaviors >
< / behavior >
< < span class =code-leadattribute> protocolmapping >
< add binding = basicHttpsBinding 方案 = https / &g t;
< / protocolmapping >
< servicehostingenvironment aspnetcompatibilityenabled = true multiplesitebindingsenabled = < span class =code-keyword> true / >


Hello everyone,

I'm facing a configuration issue concerning my WCF Streaming service. I've got a Windows service that self-hosts 3 WCF Services, one of which handles the uploading and downloading of binary content using Streams. The documentation around states that you have to set maxReceivedMessageSize to a suitably high number (eg. 2147483647) to be able to receive larger messages, which is what we did.

Service Config:

<service name="DocumentService" behaviorConfiguration="DatashopServiceBehavior">
        <endpoint contract="IDocumentService" address="DocumentService"

                  binding="basicHttpBinding" name="basicHttpBinding" bindingConfiguration=""

                  behaviorConfiguration="DatashopServiceEndpointBehavior"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/Datashop/Documents/"/>
          </baseAddresses>
        </host>
      </service>



Binding Config:

<basicHttpBinding>
<binding name="" transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"

                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"

                        maxNameTableCharCount="2147483647" />
        </binding>
</basicHttpBinding>



You'll notice that there is an empty string value for the bindingConfiguration attribute of the endpoint, and an empty string for the name attribute of the binding itself. That's because this is the only way we got it to work. If we explicitly name the binding and reference it from the endpoint using that name, it's as if the maxReceivedMessageSize property is never set and large binary contents give us the following error in the WCF Service Trace Viewer:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

My colleague has isolated the streaming service and inspected the configuration at run time using reflection and has found that the maxReceivedMessageSize is set correctly, but somehow doesn't get applied.

While we can fix our current problem by naming and referencing the binding configuration using the emtpy string, it doesn't solve the underlying issue and means if we want to set up a different endpoint on the same service but with a different binding, we can't.

Further info: the EndpointBehavior is WCFExtras to flatten the WSDL and we're not using a service client, instead we're using ChannelFactory<T>

Has anyone experienced this issue before, and what was the solution to it?

Any help will be greatly appreciated.

解决方案

The problem lies with the fact that we're self-hosting the services with the hostservice calling:

host.AddDefaultEndpoints();

We were stupidly calling the service with the baseAddress:

http://localhost:8080/Datashop/Documents/

instead of:

http://localhost:8080/Datashop/Documents/DocumentService/

What I still don't understand is why the damn thing worked when the server side had empty strings for the bindingConfiguration name, but at this stage I don't care. I care far more about the vast amounts of beer I'm going to pour down my neck to try and forget the last two days chasing a configuration issue thinking it's a bug in WCF ;)


<bindings>
      <basichttpbinding>
        <binding name="FlightInventory_basicHttpBinding" closetimeout="00:20:00" opentimeout="00:20:00">
          receiveTimeout="00:20:00" sendTimeout="00:20:00" allowCookies="false"
          bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
          messageEncoding="Text">
          <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647">
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientcredentialtype="None" proxycredentialtype="None">
              realm="" />
            <message clientcredentialtype="UserName" algorithmsuite="Default" />
          </transport></security>
        </readerquotas></binding>
      </basichttpbinding>
    </bindings>
    <services>
      <service name="FlightInventoryService.FlightInventory" behaviorconfiguration="FlightInventoryService.ServiceBehaviour">
        <endpoint address="" binding="basicHttpBinding" bindingconfiguration="FlightInventory_basicHttpBinding" contract="FlightInventoryService.IFlightInventory">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <servicebehaviors>
        <behavior name="FlightInventoryService.ServiceBehaviour">
          <!-- 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" />
          <datacontractserializer maxitemsinobjectgraph="2147483647" />
        </behavior>
      </servicebehaviors>
    </behaviors>
    <protocolmapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolmapping>
    <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />


这篇关于MaxReceivedMessageSize不适用于命名bindingConfiguration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆