none
Problem with Metadata Exchange

    Question

  • Hi!

    We have a problem with metadata exchange during proxy class generation with svcutil. This problem is closely related with size of file, that contains ServiceContract definition (for example, there is no error if some FaultContracts are commented)

    Thanks, Alexey 

    Error: Cannot obtain Metadata from http://localhost/VClassWebService/vcservice.svc/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/VClassWebService/vcservice.svc/mex

    Metadata contains a reference that cannot be resolved: 'http://localhost/VClassWebService/vcservice.svc/mex'.

    There is an error in XML document (1, 215447).

    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 215447.

    HTTP GET Error

    URI: http://localhost/VClassWebService/vcservice.svc/mex

    There was an error downloading 'http://localhost/VClassWebService/vcservice.svc/mex'.

    EXEC : The request failed with the error message:

    --

    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/fault</a:Action></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value>a:MessageAddressingHeaderRequired</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="ru-RU">No Action header was found with namespace 'http://www.w3.org/2005/08/addressing' for the given message.</s:Text></s:Reason><s:Detail><a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName></s:Detail></s:Fault></s:Body></s:Envelope>

    --.

     

    Tuesday, February 20, 2007 11:34 AM

Answers

  • You need to increase the ReaderQuotas throttle values on the binding used by svcutil, as described in the error message.

    This sample http://msdn2.microsoft.com/en-us/library/aa395212.aspx shows how to use a svcutil.exe.config file to alter the binding svcutil uses to talk to the mex endpoint.  The binding you want would look about like this:

    <customBinding>
      <
    binding name="myMex">
        <
    textMessageEncoding >
          <
    readerQuotas maxNameTableCharCount="30000"/>
        </
    textMessageEncoding>
        <
    httpTransport/>
      </
    binding>
    </
    customBinding>

    That's basically the default mex http binding, only with a larger value for the maxNameTableCharCount.  The config file would also include the client endpoint below, as suggested by the sample.

    <client>
      <
    endpoint name="http" binding="customBinding" bindingConfiguration="myMex" contract="IMetadataExchange" />
    </
    client>

    Tuesday, February 20, 2007 5:44 PM
  • The problem now is that the server's "mexTcpBinding" endpoint has no security, whereas your svcutil client's NetTcp endpoint does.  Turn off security in the svcutil binding, and I think it will work.
    Wednesday, April 11, 2007 7:38 PM

All replies

  • You need to increase the ReaderQuotas throttle values on the binding used by svcutil, as described in the error message.

    This sample http://msdn2.microsoft.com/en-us/library/aa395212.aspx shows how to use a svcutil.exe.config file to alter the binding svcutil uses to talk to the mex endpoint.  The binding you want would look about like this:

    <customBinding>
      <
    binding name="myMex">
        <
    textMessageEncoding >
          <
    readerQuotas maxNameTableCharCount="30000"/>
        </
    textMessageEncoding>
        <
    httpTransport/>
      </
    binding>
    </
    customBinding>

    That's basically the default mex http binding, only with a larger value for the maxNameTableCharCount.  The config file would also include the client endpoint below, as suggested by the sample.

    <client>
      <
    endpoint name="http" binding="customBinding" bindingConfiguration="myMex" contract="IMetadataExchange" />
    </
    client>

    Tuesday, February 20, 2007 5:44 PM
  • I have a similar sencario on net.tcp. Trying the config file option as below didn't work out. Has anyone found a solution for this?

     

    <configuration>

    <system.serviceModel>

    <client>

    <endpoint binding="netTcp" bindingConfiguration="bc" contract="IMetadataExchange" />

    </client>

    <bindings>

    <netTcpBinding>

    <binding name="bc" maxReceivedMessageSize="512000">

    <readerQuotas maxDepth="32" maxStringContentLength="8192000"

    maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384000" />

    </binding>

    </netTcpBinding>

    </bindings>

    </system.serviceModel>

    </configuration>

    Wednesday, April 11, 2007 4:10 PM
  • Honestly I have not tried it, but I think the endpoint name must be the binding scheme, so the problem is you need to add


    name="net.tcp"

     

    to your <endpoint>.

    Wednesday, April 11, 2007 4:51 PM
  • Thanks brian for your quick reply.

    net.tcp has changed the behavior and now I get this message on svcutil.exe. Is their anything else I need to configure?

    ---------------------------------------------------------------------------

    Attempting to download metadata from 'net.tcp://localhost:8000/GCS/Service/ABCService/mex' using WS-Metad
    ata Exchange. This URL does not support DISCO.
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Error: Cannot obtain Metadata from net.tcp://localhost:8000/GCS/Service/ABCService/mex

    If this is a Windows (R) Communication Foundation service to which you have access, please check tha
    t you have enabled metadata publishing at the specified address.  For help enabling metadata publish
    ing, please refer to the MSDN documentation at
    http://go.microsoft.com/fwlink/?LinkId=65455.


    WS-Metadata Exchange Error
        URI: net.tcp://localhost:8000/GCS/Service/ABCService/mex

        Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8000/GCS/Service/ABCService/mex'.

        The requested upgrade is not supported by 'net.tcp://localhost:8000/GCS/Service/ABCService/mex'. This
     could be due to mismatched bindings (for example security enabled on the client and not on the server).

    ---------------------------------------------------------------------------

    Please note metadata is being published as without the svcutil.exe.config file the proxy could be generated by removing one contract method.

     

     

    Setting debugger to break when an exception is thrown shows it as

    A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll

    Additional information: .Net Framing upgrade request for application/negotiate was sent to a service that is not setup to receive upgrades.

     

    The service side config file looks something like (identifying information has been renamed)

    <system.serviceModel>

    <bindings>

    <netTcpBinding>

    <binding name="WindowsClientOverTcp" maxReceivedMessageSize="512000">

    <readerQuotas maxStringContentLength="512000" />

    </binding>

    </netTcpBinding>

    </bindings>

    <services>

    <service behaviorConfiguration="standardBehavior" name="ABCService">

    <endpoint address="" binding="netTcpBinding" bindingConfiguration="WindowsClientOverTcp"

    contract="IABCContract" />

    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />

    <host>

    <baseAddresses>

    <add baseAddress="net.tcp://localhost:8000/GCS/Service/ABCService" />

    </baseAddresses>

    </host>

    </service>

    </services>

    <behaviors>

    <serviceBehaviors>

    <behavior name="standardBehavior">

    <serviceMetadata httpGetEnabled="false" httpGetUrl="" />

    <serviceDebug includeExceptionDetailInFaults="true" />

    <dataContractSerializer maxItemsInObjectGraph="655360" />

    </behavior>

    </serviceBehaviors>

    </behaviors>

    </system.serviceModel>


     

    Wednesday, April 11, 2007 6:46 PM
  • The problem now is that the server's "mexTcpBinding" endpoint has no security, whereas your svcutil client's NetTcp endpoint does.  Turn off security in the svcutil binding, and I think it will work.
    Wednesday, April 11, 2007 7:38 PM
  • Thanks Brian, it does work now!

     

    For anyone else encountering this problem

    1. Create a file SvcUtil.exe.config in the same directory as that of svcutil.exe
    2. Copy the below into SvcUtil.exe.config

      <?xml version="1.0" encoding="utf-8"?>

      <configuration>

      <system.serviceModel>

      <client>

      <endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="bc" contract="IMetadataExchange" />

      </client>

      <bindings>

      <netTcpBinding>

      <binding name="bc" maxReceivedMessageSize="512000">

      <readerQuotas maxNameTableCharCount="163840" />

      <security mode="None"/>

      </binding>

      </netTcpBinding>

      </bindings>

      </system.serviceModel>

      </configuration>

     

    In my case my mex binding did not require security so the security mode was none. If yours requires then remove this element.

    • Proposed as answer by paburgos Sunday, January 04, 2009 5:08 AM
    Wednesday, April 11, 2007 8:54 PM
  • The error message:
    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 

    I ran into this problem when my WCF service reached a large size.  
    I could no longer right click on the service in Visual Studio and select Update service reference.  
    I also could not run svcutil.exe without an error when my WCF service was large. 
    When I commented out some of the functions to get the size smaller, everything would work, but when I added even one function after that point, it would fail.  
    No matter what the function was.

    I found out which files needed to be changed by using process monitor while doing various operations.

    To fix these problems I had to do 5 things: 

    1) Replace the svcutil.exe.config file with:
    My file was located here: SvcUtil.exe.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <system.serviceModel>
           <client>
              <endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="GenericBinding"
                  contract="IMetadataExchange" />
              <endpoint name="http" binding="wsHttpBinding" bindingConfiguration="SecureBinding" contract="IMetadataExchange" />
           </client>
           <bindings>
            <netTcpBinding>
              <binding name="GenericBinding" maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647" >
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                 maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                 maxNameTableCharCount="2147483647" />
                <security mode="None"/>
              </binding>
            </netTcpBinding>
            <wsHttpBinding>
              <binding name="SecureBinding" maxBufferPoolSize="2147483647" 
                 maxReceivedMessageSize="2147483647" >
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                 maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                 maxNameTableCharCount="2147483647" />
                <security mode="Message">
                  <transport clientCredentialType="Windows" />
                </security>
              </binding>
            </wsHttpBinding>
          </bindings>
         </system.serviceModel>
    </configuration>


    2) Add the client endpoints and the <bindings> element to your machine.config.
    My file was located here: C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

    3) Add the whole <System.ServiceModel> inside your devenv.exe.config
    My file was located here: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.config

    4) Modify the endpoint and bindings of my client app. (myapp.exe.config)

    5) Modify the endpoints and bindings of my WCF service. (mywcfservice.exe.config)
    Saturday, November 21, 2009 4:58 AM
  • For posterity sake.

    The problem is not the endpoint name, but the endpoint binding.  There is no such binding as "netTcp".  It should had been "netTcpBinding".

    Then of course, Srinvias would still run into the whole security issue with mexTcpBinding and netTcpBinding.  But your subsequent reply would fix that issue.

     

    Friday, October 15, 2010 8:48 AM