WCF 服务参考支持文件未更新 [英] WCF Service Reference Support Files Not Updating

查看:27
本文介绍了WCF 服务参考支持文件未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 VS 2010 解决方案,其中包含一个 WCF 服务项目和一个单元测试项目.单元测试项目有一个对 WCF 服务的服务引用.

WCF 服务项目的 Web.config 将许多绑定属性设置为非默认值:

web.config:(特别注意 maxBufferSize="20000000")

<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"><readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/><安全模式="TransportCredentialOnly"><传输 clientCredentialType="Ntlm"/></安全></binding></basicHttpBinding>

在检查这个问题时,我开始意识到单元测试项目的服务引用支持文件不包含我期望的值(即 WCF 服务的 web.config 中配置的值):

configuration.svcinfo:(特别注意maxBufferSize=65536")

 <readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"/><安全模式=无"><message algorithmSuite="Default" clientCredentialType="UserName"/><transport clientCredentialType="None" proxyCredentialType="None" realm=""/></安全></binding>

删除并重新创建服务引用或更新服务引用会重新创建文件,但我仍然得到相同的值.

为什么?

更新

这是客户端的app.config

<readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"maxBytesPerRead="200000000" maxNameTableCharCount="200000000"/><安全模式=无"><transport clientCredentialType="None" proxyCredentialType="None"领域=""/><message clientCredentialType="UserName" algorithmSuite="默认"/></安全></binding>

解决方案

这里同样的问题,折腾了半天配置文件后没有解决方案...更改自动生成的文件通常是不受欢迎的,所以我的感觉是必须有更好的方法,丹尼斯".

更新:我通过删除绑定配置中的 name 属性解决了我的问题.所以你当前的 web.config 看起来像这样

<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"><readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/><安全模式="TransportCredentialOnly"><传输 clientCredentialType="Ntlm"/></安全></binding></basicHttpBinding>

会变成

<binding maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"><readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/><安全模式="TransportCredentialOnly"><传输 clientCredentialType="Ntlm"/></安全></binding></basicHttpBinding>

我认为您只需要在客户端执行此操作.根据我的理解,通过删除 name 属性,您实质上更改了应用程序的默认 basicHttpBinding 配置.此解决方案的积分此处.>

另一个更新:如果您正确命名您的服务配置(包括命名空间),它将选择绑定配置.所以代替

你需要

I have a VS 2010 solution containing a WCF service project and a unit test project. The unit test project has a service reference to the WCF service.

Web.config for the WCF service project sets a number of binding attributes to other-than-default values:

web.config: (Specifically note maxBufferSize="20000000")

<basicHttpBinding>
    <binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm"/>
      </security>
    </binding>
</basicHttpBinding>

While examining this issue, I came to realize that the unit test project's service reference support files do not contain the values I would expect (i.e. the values configured in the WCF service's web.config):

configuration.svcinfo: (Specifically note maxBufferSize="65536")

  <binding hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" messageEncoding="Text" name="BasicHttpBinding_IBishopService" textEncoding="utf-8" transferMode="Buffered">
    <readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192" />
    <security mode="None">
      <message algorithmSuite="Default" clientCredentialType="UserName" />
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    </security>
  </binding>

Deleting and re-creating the service reference or updating the service reference re-creates the files, but I still end up with the same values.

Why?

Update

Here's the app.config of the client

<binding name="BasicHttpBinding_IMyService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"
                        maxBytesPerRead="200000000" maxNameTableCharCount="200000000" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>

解决方案

Same issue here and no solution after half a day messing about with config files... Changing automatically generated files is usually frowned upon, so my feeling says that "there has got to be a better way, Dennis".

UPDATE: I got my problem fixed by removing the name attribute in the binding configuration. So your current web.config is looking like this

<basicHttpBinding>
  <binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
    <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Ntlm"/>
    </security>
  </binding>
</basicHttpBinding>

would become

<basicHttpBinding>
  <binding maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
    <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Ntlm"/>
    </security>
  </binding>
</basicHttpBinding>

I think you only need to this at the client-side. By removing the name attribute, you essentially change the default basicHttpBinding configuration for your app, as far as I understand it. Credits for this solution here.

Another update: if you name your service configuration correctly (including the namespace) it will pick up the binding configuration. So instead of

<service name="ServiceName">

you need

<service name="My.Namespace.ServiceName">

这篇关于WCF 服务参考支持文件未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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