0

I cannot get to work a wsDualHttpBinding endpoint on my WCF service. I'm facing this problem on the client.

I get an exception that suggests to increment MaxArrayLength from 16384 to allow to read the whole xml data.

I tried the following configuration:

 <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="MyBinding" maxReceivedMessageSize="2147483647" />
      </wsDualHttpBinding>
    </bindings>

    <client>
      <endpoint name="WSDualHttpBinding_IDataService" binding="wsDualHttpBinding" bindingConfiguration="MyBinding"
        address="http://localhost:8733/DataProvider/" contract="DataStorageService.IDataService" >
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>

But the above configuration seems to be ignored.

I instantiate my client like this:

  var instanceContext = new InstanceContext( new CallbackHandler() );
  _clientService = new DataServiceClient( instanceContext );

and i read somewhere that these line of codes override the configuration in app.config; if that't the problem, how can i increment quotas?

Any help appreciated.

Mauro Sampietro
  • 2,739
  • 1
  • 24
  • 50

2 Answers2

2

You have to configure more than just maxReceivedMessageSize. As Jonathan Coffey said, there is BytePerRead, TableCharCount, StringContentLenght, etc. You also have to configure the readerQuotas : https://msdn.microsoft.com/en-us/library/ms731325(v=vs.110).aspx

Note that you have to configure the server the exact same way you configured your client, and you can't set a maxbytearraylengh't greater than your maxreceivedmessagesize, obviously. If the server doesn't have the same MaxReceivedMessageSize or whatever, it won't work as you expected, for example.

GL.

Ahonir
  • 142
  • 1
  • 6
1

You do exactly what the error tells you :)

For this it might be best to see visually how to do it rather than copy and paste code.

In your project, Right click your service "app.config" and choose "Edit WCF Configuration" from there click on "Bindings" and you should see your custom binding. If not just right click and create a new binding. From here you can change the "ReaderQuotas Properties" what I use is

MaxArrayLength = 2147483647
MaxBytesPerRead = 4096
MaxDepth = 32
MaxNameTableCharCount = 2147483647
MaxStringContentLength = 2147483647

Once that is done, go ahead and press "File" and then "Save"

Now go view your app.config code and it should have updated.

Run your service and then right click your service references and "Update Service Reference"

Now if you look at your client app.config file it should match what your service app.config attributes looked like. If this is not the case then right click your clients app.config and "Edit WCF Configuration" again, go to bindings and then choose your service endpoint and change the values to the same as the service.

Be aware though settings the values that high will leave you vulnerable to ddos attacks etc. so find out what you need and change it after testing.

Hope this helps :)

Make sure your service is running as administrator also

Jonathan Coffey
  • 570
  • 4
  • 10
  • This seems like the procedure to solve it on the server side isn'it? I'm getting the erro on the client side – Mauro Sampietro Sep 20 '16 at 09:05
  • Well if your server side isn't set up right then it's not going to even send to the client.. I explained both client and server, they are a similar process – Jonathan Coffey Sep 20 '16 at 09:56