简体   繁体   English

基本HttpBinding的WCF服务配置

[英]WCF Service Configuration for basicHttpBinding

I am having an issue where I have SOA with a web site consuming services and a web site hosting services. 我有一个SOA,其中一个网站使用服务,另一个网站托管服务。 One of my services accepts an image (byte[]). 我的一项服务接受图像(byte [])。 When I pass an image of 83kb to the WCF service I get the following error: 当我将83kb的图像传递给WCF服务时,出现以下错误:

The maximum array length quota (16384) has been exceeded while reading XML data. 读取XML数据时,已超出最大数组长度配额(16384)。 This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. 通过更改在创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额。

There is no specific config in my server side configuration for this service. 我的服务器端配置中没有针对此服务的特定配置。 The following is in my consuming web application web.config file: 以下是我正在使用的Web应用程序的web.config文件:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
          <binding name="BasicHttpBinding_ISchoolSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="false">
          <readerQuotas maxDepth="32" maxStringContentLength="998192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:50977/Interface/Schools.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISchoolSettings" contract="Services.Schools.ISchoolSettings" name="BasicHttpBinding_ISchoolSettings" />
    </client>
  </system.serviceModel>

It looks like .net is ignoring the fact I've set MaxArrayLength=2147483647 for this binding configuration. 似乎.net忽略了我已为此绑定配置设置MaxArrayLength=2147483647的事实。

I am using .net 4.0 here. 我在这里使用.net 4.0 Curiously, I have a machine with .net 4.5 on it and I DONT get this error on that machine!! 奇怪的是,我有一台机器上装有.net 4.5 ,但我没有在该机器上收到此错误!

I've tried all sorts but cant seem to get around this issue. 我已经尝试了各种方法,但似乎无法解决该问题。

Make sure you change the setting on both the client config and the service config. 确保同时更改客户端配置和服务配置上的设置。 It can be a bit confusing sometimes to see where the exception is actually occurring. 有时看到实际发生异常的地方可能会使您感到困惑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM