Today I’ve hit the size limit for a WCF service contract. It might seem unbelievable, but it’s almost true.
I have a service contract with about 40 operations. After adding a new method to the contract, I get an error from the WCF Test Client:
Error: Cannot obtain Metadata from http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex Metadata contains a reference that cannot be resolved: 'http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'. There is an error in XML document (1, 110009). The value for the 'base' attribute is invalid - 'q1:EntityObject' is an invalid value for the 'base' attribute..HTTP GET Error URI: http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex There was an error downloading 'http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'. The request failed with HTTP status 400: Bad Request.
Same error if i attempt to add this service to a project. The message seems to change depending on which method I leave out, or put in. It seems to be getting hilarious, but it’s not. Accidentally, i got this error(truncated):
There is an error in XML document The maximum nametable character count quota (16384) has been exceeded while reading XML data.
After a bit of searching online, I found out that this is a recognized issue with the default metadata exchange binding, here. The workarounds didn’t look good at all to me, so I continued searching. Then, I came across this, which looks a lot more promising.
I created a custom wsHttpBinding that I used for the meta data contract. Now the task was to get the Visual Studio IDE and the WCF Test Client to use this binding when adding or updating a service reference. In order for this, corresponding bindings must be configured for each tool, in its .exe.config file. The binding must be identical with the one on the service side, and it must have a name that corresponds to the protocol used by it (http, https, net.tcp).
There are 3 places(files) that need to be updated: devenv.exe.config, WcfTestClient.exe.config and SvcUtil.exe.config. Actually, if you have several versions of the Windows SDK installed, you might have more than 3 places to modify. My advice is to do a search for each of the config file names and change as many of them as required in order to get your work back on track.
I would have thought that the mexHttp(s)Binding would allow for custom quotas for the reader. Perhaps in .NET 4.0? (vote here if it hurts)