WCF Service Hosted in IIS 7 - Binding Configuration Settings Ignored

I have a WCF service operation that takes a byte array as part of a data contract. The service is distributed only domestically (and not on the Internet), and I want to increase quotas to allow an array of 10 MB in size.

The service is hosted on IIS7. When I try to send an array of bytes by default, I get the following exception message:

Error deserializing an object of type MyService.ServiceContracts.Data. The maximum length length of the array (16384) was exceeded when reading XML data. This quota can be increased by changing the MaxArrayLength property to the XmlDictionaryReaderQuotas object used to create the XML reader. Line 1, position 22991.

Here's the configuration:

<system.serviceModel> <netTcpBinding> <binding name="largeBinaryBinding" maxReceivedMessageSize="10001000" maxBufferPoolSize="80008000" maxBufferSize="10001000" receiveTimeout="00:01:00" openTimeout="00:01:00" closeTimeout="00:01:00" sendTimeout="00:01:00"> <readerQuotas maxArrayLength="10000000" /> </binding> </netTcpBinding> <services> <service name="MyService"> <endpoint binding="netTcpBinding" bindingConfiguration="largeBinaryBinding" bindingNamespace="http://my.services.co.uk/MyService" contract="Services.MyService.ServiceContracts.IMyService" /> </service> </services> </system.serviceModel> 

Thus, my configuration allows you to receive larger messages, but IIS seems to ignore this - how can I stop this and allow larger messages?

+4
source share
1 answer

Again, right after I submit the question, I find the answer!

When using WAS, you need to specify the fully qualified class name of the service in the configuration service name. So in my example, I had a service implementation class called MyService in the Services namespace. Therefore, in the configuration I need

 <service name="Services.MyService"> ... 

Otherwise, IIS silently ignores your elaborate configuration! How convenient.

+9
source

Source: https://habr.com/ru/post/1382717/


All Articles