wcf Your first service Adding a metadata endpoint to your service

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.

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

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.



Got any wcf Question?