用web服务发送一个大阵列
我看过很多解决方案来解决我的问题,但我没有找到对我有用的任何东西。用web服务发送一个大阵列
我的问题很简单:我无法通过webservice发送长字节数组。我可以发送一个代表4千字节但没有更大的图像的数组。
这是客户端配置
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICespitiAVService" closeTimeout="02:00:00"
openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51366/CespitiAVService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICespitiAVService"
contract="CespitiAVService.ICespitiAVService" name="BasicHttpBinding_ICespitiAVService"/>
</client>
</system.serviceModel>
</configuration>
这是服务器配置
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="655360"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
哪里有人说把readerquotas也是在客户端的配置已经阅读解决方案,但XML赢得”不接受它,说它只接受安全节点。
有人说在客户端配置中更改transfermode会解决问题,但我只能使用缓冲模式,它不接受其他任何东西。
我用过fiddler,它说程序超过了maxarraylength,你可以看到我在web.config中改变了这个值,但是我不能在客户端配置中更改,因为它表示绑定节点没有readerquotas属性。
我想你需要在客户端上设置DataContractSerializer的maxItemsInObjectGraph属性的端点行为配置。您还应该将readerQuotas添加到客户端的绑定配置中。这应该工作:
客户:
<behaviors>
<endpointBehaviors>
<behavior name="ICespitiAVService_Behavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICespitiAVService" closeTimeout="02:00:00"
openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51366/CespitiAVService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ICespitiAVService"
behaviorConfiguration="ICespitiAVService_Behavior"
contract="CespitiAVService.ICespitiAVService"
name="BasicHttpBinding_ICespitiAVService"/>
</endpoint>
</client>
服务器:
<bindings>
<binding name="LargeMessages" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxDepth="32" />
</binding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ICespitiAVService.Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ICespitiAVService.Behavior" name="ICespitiAVService">
<endpoint address="" binding="basicHttpBinding"
contract="CespitiAVService.ICespitiAVService"
bindingConfiguration="LargeMessages"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:51366/" />
</baseAddresses>
</host>
</service>
</services>
正如我在我的第一篇文章中所说,我不能在客户端配置中添加readerquotas,至于dataContractSerializer,我已经将它添加到web.config中,并且我给它提供了maxint值 – zizzi 2012-03-14 08:16:55
默认情况下VS2010会创建readerquotas,当我添加一个新的服务参考,所以这绝对有可能。 – Andreas 2012-03-14 16:03:39
我知道,但是当我创建或更新服务引用,我可以在clientconfig maxBufferSize maxReceivedMessageSize中找到预期的,但我无法找到readerquotas,即使我在web.config中创建它们,如果你想我也可以做一个截图您可以看到我无法在客户端配置中创建readerquotas – zizzi 2012-03-14 16:08:42
的问题是在客户端配置,因为我不能添加readerquotas,我已经试图再次创造配置文件,但没有任何变化,我已经创建了一个新的虚拟项目,看看我是否可以将rederquotas添加到客户端配置,但我再也不能这样做 – zizzi 2012-03-14 08:24:24
是的,我遇到了同样的情况。 .ClientConfig似乎与应用程序或web.config文件不同。任何方案? – 2012-10-22 08:09:40