svcutil and the infamous This URL does not support DISCO

WCF is undoubtedly a complex beast, and sometimes you gets stuck on some strange errors. Suppose you have this configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<host>
    <baseAddresses>
        <add baseAddress="http://localhost:9000/L4NServer/"/>
        <add baseAddress="net.tcp://localhost:8000/L4NServer/"/>
    </baseAddresses>
</host>
<endpoint
      address="MainLog"
      binding="basicHttpBinding"
      contract="LiveLogger4Log4Net.IL4NServer" />

you can generate the proxy with the command

svcutil http://localhost:9000/L4NServer/ /out:client.cs /config:service.config

suppose you want to switch over net.tcp binding, you change the binding for the endpoint (netTcpBinding), you try to generate again the proxy classes with svcutil

svcutil net.tcp://localhost:8000/L4NServer/ /out:client.cs /config:service.config

and surprise… it does not work, and you get some strange error like the following

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
Attempting to download metadata from 'net.tcp://localhost:8000/L4NServer/MainLog
' using WS-Metadata Exchange. This URL does not support DISCO.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation.  All rights reserved.

Error: Cannot obtain Metadata from net.tcp://localhost:8000/L4NServer/MainLog

If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess.  For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
    URI: net.tcp://localhost:8000/L4NServer/MainLog

    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:
8000/L4NServer/MainLog'.

    The socket connection was aborted. This could be caused by an error processi
ng your message or a receive timeout being exceeded by the remote host, or an un
derlying network resource issue. Local socket timeout was '00:05:00'.

If you read the messages you could suspect that something on the network does not work properly, at least you read the socket connection was aborted but the interesting part of the message is error: cannot obtain metadata from… this is the real error messages. To understand why this error occurred read this page, but if you are interested in the solution you can add this to the configuration

1
2
3
4
5
6
7
8
<endpoint
      address="MainLog"
      binding="netTcpBinding"
      contract="LiveLogger4Log4Net.IL4NServer" />
<endpoint
      address="mex"
      binding="mexTcpBinding"
      contract="IMetadataExchange" />

As you can notice I added an endpoint of type IMetadataExchange for the mexTcpBinding, now if you run again the svcutil tool the generation of the client classes will succeed.

alk.

Tags: WCF .NET Framework

DotNetKicks Image