我有一个VS 2010解决方案,包含一个WCF服务项目和一个单元测试项目。单元测试项目具有对WCF服务的服务引用。
WCF服务项目的Web.config将许多绑定属性设置为其他默认值:
maxBufferSize="20000000"):web.config: (特别注意事项)
<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>在检查this issue时,我意识到单元测试项目的服务引用支持文件不包含我期望的值(即在WCF服务的web.config中配置的值):
configuration.svcinfo: (特别注意到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>删除和重新创建服务引用或更新服务引用重新创建文件,但我的结果仍然是相同的值。
为什么?
更新
这是客户机的app.config
<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>发布于 2011-10-03 10:29:36
同样的问题,在半天处理配置文件后没有解决方案.更改自动生成的文件通常是不赞成的,所以我的感觉是“必须有更好的方法,丹尼斯”。
更新:我通过删除绑定配置中的name属性解决了我的问题。所以你现在的web.config是这样的
<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>会变成
<basicHttpBinding>
<binding maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>我认为你只需要在客户端处理这个问题。通过删除name属性,您实际上更改了应用程序的默认basicHttpBinding配置,据我所知。此解决方案的学分here。
另一个更新:如果您正确命名您的服务配置(包括名称空间),它将获得绑定配置。所以而不是
<service name="ServiceName">你需要
<service name="My.Namespace.ServiceName">发布于 2011-09-24 10:11:12
这是正确的行为。绑定中包含的一些信息只针对配置的一方,客户机和服务器都可以使用完全不同的值。此外,这些值是防止拒绝服务附加的,因此服务不想公开显示它们。
这些值只影响传入消息的处理,因此服务配置它将如何处理传入请求,客户端配置它将如何处理传入响应。请求和响应可以有不同的特征和不同的配置。如果服务总是只接收少量KB请求并返回1MB响应,则不需要将服务配置为接受1MB请求。
顺便说一句。这是WCF特有的特性,与一般的web服务无关,因此在WSDL中没有标准的方法来描述这一点。
https://stackoverflow.com/questions/7536550
复制相似问题