WCF绑定配置仅应用于默认,但如果命名失败 [英] WCF binding configuration apply only as default but as named it fails

查看:197
本文介绍了WCF绑定配置仅应用于默认,但如果命名失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个有趣的问题与WCF绑定和流传输模式,我们不能解决:



我们有一个WCF端点配置为流传输模式。端点接收的消息比默认大小(〜65 KB)大得多。因此,我们在绑定标记的maxReceivedMessageSize属性中指定了更大的消息大小。



问题是当我们通过端点标签上的 bindingConfiguration 属性配对端点和绑定时,我们收到以下错误:远程服务器返回错误:(400)错误请求。

$ b $ b

一旦我们删除了两个属性 bindingConfiguration name ,它就会正常工作,而不会出错。



以下是服务端点的定义:

 < service name =服务.DocumentServicebehaviorConfiguration =ServiceBehavior> 
< endpoint contract =ServiceContracts.IDocumentServiceaddress =DocumentService
binding =basicHttpBindingname =basicHttpBinding
bindingConfiguration =BindingConfiguration go away
behaviorConfiguration =ServiceEndpointBehavior/>
< host>
< baseAddresses>
< add baseAddress =http:// localhost:8080 / Documents //>
< / baseAddresses>
< / host>
< / service>

以下是绑定配置



< binding
name =BindingConfiguration&-----当它离开
transferMode =StreamedmaxReceivedMessageSize = 2147483647>
< readerQuotas maxDepth =2147483647maxStringContentLength =2147483647
maxArrayLength =2147483647maxBytesPerRead =2147483647
maxNameTableCharCount =2147483647/>
< / binding>

所以它只作为默认绑定(没有明确命名的键)。奇怪的是,我们能够通过服务主机上的反射来验证在这两种情况下实际应用绑定配置(maxReceivedMessageSize设置正确)。





任何想法都是非常赞赏的?

解决方案

我们最近发现,初始化代码明确使用默认设置,因此忽略了web.config中的。



我们删除了那部分代码,并且应用了来自web.config的设置。



一个愚蠢的错误。



感谢大家的答案


We have an interesting problem with WCF binding and streaming transfer mode that we cannot solve:

We have an WCF endpoint configured to the streaming transfer mode. The endpoint receives message much larger then the default size (~65 KB). Therefore we have specified larger message size in the maxReceivedMessageSize attribute on the binding tag.

The problem is when we pair up the endpoint and the binding by the bindingConfiguration attribute on the endpoint tag and the name attribute on the binding tag, we receive the following error: "The remote server returned an error: (400) Bad Request".

As soon as we remove both attributes bindingConfiguration and name it works without an error.

Here is the definition of the service endpoint:

    <service name="Services.DocumentService" behaviorConfiguration="ServiceBehavior">
    <endpoint contract="ServiceContracts.IDocumentService" address="DocumentService"
              binding="basicHttpBinding" name="basicHttpBinding" 
      bindingConfiguration="BindingConfiguration"     <---- when this goes away
              behaviorConfiguration="ServiceEndpointBehavior"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/Documents/"/>
      </baseAddresses>
    </host>
    </service>

Here is the binding configuration:

    <binding  
      name="BindingConfiguration" <---- and when this goes away
     transferMode="Streamed" maxReceivedMessageSize="2147483647"  >
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
    </binding>

So it only works as default binding (without explicitly named key). The strange thing is that we were able to verify by reflection on the Service host that the binding configuration is actually applied (the maxReceivedMessageSize was set correctly) in both scenarios. Could it be a bug in WCF?

The service is self-hosted.

Any ideas are very appreciated?

解决方案

We have recently found out that the initialization code used explicitly the default settings and thus ignored those in the web.config.

We removed that part of code and the setting from the web.config got applied.

A stupid error.

Thanks everybody for thier answers

这篇关于WCF绑定配置仅应用于默认,但如果命名失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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