0

i've looked to a lot of solutions to resolve my problem but i didn't found anything good for me.

my problem is simple: i can't send a long array of bytes through the webservice. I can send an array that represents an image of 4 Kbytes but nothing bigger.

this is the client configuration

    <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>

this is the server 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>

I've read solutions where somebody said to put the readerquotas also in the client config but the xml won't accept it, saying that it accepts only security nodes.

Somebody says that changing the transfermode in the client config will resolve the problem, but i can use only the buffered mode it doesn't accept anything else.

I've used fiddler and it says that the program exceeds the maxarraylength, as you can see I've changed this value in the web.config but i can't change in the client config because it says that the binding node doesn't have the readerquotas property.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
zizzi
  • 11
  • 5

2 Answers2

0

Just try to create new configuration files following Maximum array length quota (solved my problem) and see whether it's solve your problem or not, because i think the problem is due to your configurations files.

Community
  • 1
  • 1
Ouadie
  • 13,005
  • 4
  • 52
  • 62
  • the problem is in the client config because i can't add the readerquotas, i've already tried to create again the config files but nothing changes, i've created a new dummy project to see if i could add the rederquotas to the client config, but again i couldn't do that – zizzi Mar 14 '12 at 08:24
  • Yes I'm experiencing the same thing. .ClientConfig seems to be different than a app or web.config file. Any Solutions? – Christopher Leach Oct 22 '12 at 08:09
0

I think you need an endpoint behavior configuration on the client that sets the DataContractSerializer's maxItemsInObjectGraph property. You should also add the readerQuotas to your client's binding configuration. This should work:

Client:

<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>

Server:

<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>
Andreas
  • 6,447
  • 2
  • 34
  • 46
  • as i said in my first post i can't add the readerquotas in the client config, as for the dataContractSerializer i've already add it to the web.config and i gave it the maxint value – zizzi Mar 14 '12 at 08:16
  • VS2010 per default creates readerquotas when I add a new service reference, so that's definitely possible. – Andreas Mar 14 '12 at 16:03
  • i know but when i create or update the service references i can find in the clientconfig maxBufferSize maxReceivedMessageSize as expected but i can't find the readerquotas even if i create them in the web.config if you want i can also do a screenshot so you can see that i can't create the readerquotas in the client config – zizzi Mar 14 '12 at 16:08
  • Even the [documentation](http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.readerquotas.aspx) mentions that it's possible. If you can't do that, you've got to elaborate a little bit more on what error you get. Have you tried using the config that I posted instead of yours? Like copy&paste, compiled and run? What does it mean when you say "I can't _find_ the readerquotas"? Where would you expect to "find" them? Have you tried creating the binding in code and passing that to the service client constructor? – Andreas Mar 14 '12 at 21:29
  • this is what i mean http://img215.imageshack.us/img215/8065/immagine3yh.png Translation:"the element "binding" has a son element not valid "readerQuotas". Elements accepted "security". I've also tried through the code but it doesn't accept. I've tried also to copy & paste your code but it gives the same problem – zizzi Mar 15 '12 at 08:30
  • I fear that I can't help you. I tried to look around the web and think that you may be using silverlight. If that's true you should add the silverlight tag and hope that someone with experience there can help you. – Andreas Mar 15 '12 at 12:16