WCF metadata error

countrymeister used Ask the Experts™
I have a wcf service running, which I am trying to get the metadata for proxy generation using svcutil

When i execute the command from svcutil I get the following error
WS-Metadata Exchange Error
    URI: http://devweb4/Service2/Setup.svc

    Metadata contains a reference that cannot be resolved: 'http://devweb4/Service2/Setup.svc?wsdl'

    The HTTP request is unauthorized with client authentication sc
s'. The authentication header received from the server was 'Negoti

    The remote server returned an error: (401) Unauthorized.

I can browse to the svc which is hosted in IIS and I do see the svcutil command link on the page it shows while browsing.
The config file has the following within the services tag
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
and the following in the behaviours
				<behavior name="SetupBehavior">
					<serviceDebug includeExceptionDetailInFaults="true" />
					<serviceMetadata httpGetEnabled="true" />

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior System Engineer
Reason for this might be: Metadata is very large, and youll have to have svcutil use a custom

Solution can be: This involves making a svcutil.exe.config with an client endpoint named
http that has a customBinding with httpTransport and textMessageEncoding with the
ReaderQuotas adjusted. (That is, you need to adjust the svcutil ReaderQuotas, not
the services ReaderQuotas.) This also means youll have to call svcutil from the
command line.(If you want to use Visual Studio's Add Service Reference you will
need to make the change below to the machine.config file:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config, see the
attached machine.config for this).

The SvcUtil.exe.config file should look as follows:

<?xml version="1.0" encoding="utf-8"?>
<binding name="MyBinding">
<readerQuotas maxDepth="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<httpTransport maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" />
<endpoint binding="customBinding" bindingConfiguration="MyBinding"
name="http" />

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial