问题
I have a WCF service operation that accepts a byte array as part of its data contract. The service is only exposed internally (not to the internet), and I want to increase the quotas to allow for a 10MB byte array.
The service is hosted in IIS7. When I try to send a byte array over the default length, I get the following exception message:
There was an error deserializing the object of type MyService.ServiceContracts.Data. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating 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>
So my configuration allows for larger messages, but IIS seems to be ignoring this - how do I stop this and allow large messages through?
回答1:
Again, just after I post a question I discover the answer!
When using WAS, you need to specify the full class name of the service in the configuration's service name. So in my example, I had my service implementation class called MyService
, in the namespace Services
. Therefore, in the configuration, I need
<service name="Services.MyService">
...
Otherwise IIS silently ignores your carefully crafted configuration! How convenient.
来源:https://stackoverflow.com/questions/8243914/wcf-service-hosted-in-iis-7-binding-configuration-settings-are-ignored