我已经找了很多解决方案来解决我的问题,但我没有发现任何对我有益的事情。
我的问题很简单:我无法通过webservice发送一长串字节。我可以发送一个代表4 Kbytes但不大的图像的数组。
这是客户端配置
<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>
我已经阅读了解决方案,其中有人说将阅读器配置也放在客户端配置中,但xml不接受它,说它只接受安全节点。
有人说改变客户端配置中的transfermode会解决问题,但我只能使用缓冲模式,它不接受任何其他内容。
我已经使用了fiddler并且它说程序超出了maxarraylength,因为你可以看到我在web.config中更改了这个值,但是我无法在客户端配置中更改,因为它说的是绑定节点没有readerquotas属性。
答案 0 :(得分:0)
尝试在Maximum array length quota之后创建新的配置文件(解决了我的问题)并查看它是否解决了您的问题,因为我认为问题是由于您的配置文件造成的。
答案 1 :(得分:0)
我认为您需要在客户端上设置端点行为配置,以设置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>