客户端中的WCF绑定属性 [英] WCF binding properties in the client

查看:66
本文介绍了客户端中的WCF绑定属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感到我已经错误地确信,就像您在客户端应用程序中为WCF服务进行更新服务参考一样,后者从中获取诸如maxStringContentLength之类的最新值.您的合同在 Web.config 中的绑定并更新其自己的绑定详细信息,因此客户端&服务可以根据可以传递的最大字符串大小进行可接受的数据交换.

我已经花了很多时间试图理解为什么这实际上不起作用,即,当我们在客户端进行参考更新时,它会为所有此类绑定属性生成错误的(默认)值.例如,它总是创建maxStringContentLength="8192" :(

那里有太多的帖子试图使人们理解,但没有任何有价值的信息.

有些人建议使用外部配置,这不好,因为我的客户端需要添加引用并远程启动正确的绑定.其他人建议在添加引用后对客户端进行修改,这太愚蠢了,反正无法正常工作.有人说给服务全名或使用未命名的绑定配置对他们有帮助,但这全都是在读咖啡渣,并没有给我带来任何结果.

那么,我们如何在WCF服务端配置 Web.config 以确保其客户端在添加或更新对该服务的引用时可以自动选择正确的绑定参数?

服务的 Web.config 中的配置代码段:

I feel I''ve been wrongfully confident that just as you do Update Service Reference for a WCF Service in your client application, the latter picks up the latest values for things like maxStringContentLength from your contract''s binding in Web.config and updates its own binding details, so client & service can have agreeable data exchange as per the maximum string size that can be passed.

I have already killed numerous hours trying to comprehend why on earth this doesn''t work, i.e. when we do the reference update on the client side it generates the wrong (default) values for all such binding properties. For example, it always creates maxStringContentLength="8192" :(

There are so many posts out there of people trying to make sense out of it, but nothing of good value.

Some suggest use of external configuration, which is no good, because my client needs to add reference and initiate correct binding remotely. Others suggest modification of the client side after adding the reference, which is overly stupid and doesn''t work anyway. There are those who say that giving service full name or using unnamed binding configuration helped them, but it''s all reading off coffee grounds, and gave me no result.

So how do we configure Web.config on the WCF Service side to make sure its clients can automatically pick up the right binding parameters when adding or updating reference to the service?

Configuration snippet from the service''s Web.config:

<services>
    <service name="MyService">
        <host>
            <baseAddresses>
                <add baseAddress="http://localhost:1234/"/>
            </baseAddresses>
        </host>
        <endpoint address="MyService.svc" binding="basicHttpBinding" contract="MyNamespace.IMyService"/>
    </service>
</services>
<bindings>
    <basicHttpBinding>
        <binding sendTimeout="00:50:00" receiveTimeout="00:40:00">
            <readerQuotas maxStringContentLength="100000"/>
        </binding>
    </basicHttpBinding>
</bindings>

推荐答案

尝试一下:
使maxstringcontent起作用 [
Try this:
getting maxstringcontent to work[^]

In it the answer below states you must have both the binding AND behavior defined.


这篇关于客户端中的WCF绑定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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