views:

185

answers:

1
+1  Q: 

WCF mex too large

I have a mex binding that exceeds the reader quota of 16k. I know how to increase the size of the basicHttpBindings mut the mexHttpBinding does not allow for the same increase of buffer sizes etc.

I cannot just break the service up into smaller services. Because our website has to deal with the requests even though our production server deals with the Business logic and data handling, we had to write a custom routing service due to only having IIS6.

Can anyone suggest a solution to increase the size allowed for the mex file?

Here is the actual error:

Error: Cannot obtain Metadata from http://localhost:8021/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:8021/mex Metadata contains a reference that cannot be resolved: 'http://localhost:8021/mex'. There is an error in XML document (1, 148711). The maximum nametable character count quota (16384) has been exceeded while reading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 148711.HTTP GET Error URI: http://localhost:8021/mex There was an error downloading 'http://localhost:8021/mex'. The request failed with HTTP status 400: Bad Request.

+1  A: 

Try the following custom binding for the mex endpoint:

<customBinding>
<binding name="customMex">
        <textMessageEncoding>
    <readerQuotas maxDepth="2147483647"
      maxStringContentLength="2147483647"
      maxArrayLength="2147483647"
      maxBytesPerRead="2147483647"
      maxNameTableCharCount="2147483647" />
        </textMessageEncoding>
    <httpTransport transferMode="Buffered"
      maxReceivedMessageSize="2147483647"
      maxBufferSize="2147483647"/>
</binding>

You can modify the sizes if you like and reference the binding with an endpoint like below:

    <endpoint address="mex"
    binding="customBinding" 
    contract="IMetadataExchange" 
    name=""
    bindingConfiguration="customMex" 
    listenUriMode="Explicit" />

Svcutil Config Override

If you're using svcutil, it has it's own limits specified that can be overridden by creating a config file, as described in this Geeks With Blogs Article

Tanner
Hi Tanner. I tried your method but it did not do what I needed. If you look at the edit I put in my post, it reflects the error I still get after the proposed fix.
Johannes