wcf Your first service Adding a metadata endpoint to your service


SOAP services can publish metadata that describes the methods that may be invoked by clients. Clients can use tools such as Visual Studio to automatically generate code (known as client proxies). The proxies hide the complexity of invoking a service. To invoke a service, one merely invokes a method on a client proxy.

First you must add a metadata endpoint to your service. Assuming your service looks the same as the one defined in the "First service and host" example, you can make the following changes to the configuration file.

      <behavior name="serviceBehaviour">
        <serviceMetadata httpGetEnabled="true" />
    <service name="Service.Example" behaviorConfiguration="serviceBehaviour">
      <endpoint address="mex" binding="mexHttpBinding" name="mexExampleService" contract="IMetadataExchange" />
      <endpoint name="netTcpExample" contract="Service.IExample" binding="netTcpBinding" />
          <add baseAddress="net.tcp://localhost:9000/Example" />
          <add baseAddress="http://localhost:8000/Example" />

The mexHttpbinding exposes the interface over http, so now you can go with a web browser to

http://localhost:8000/Example http://localhost:8000/Example?wsdl

and it will display the service and its metadata.