What is the importance of IMetadataExchange in WCF?

wcf

Solution

IMetadataExchange Interface Exposes methods used to return metadata about a service. When programming Windows Communication Foundation (WCF) services, it is useful to publish metadata about the service. For example, metadata can be a Web Services Description Language (WSDL) document that describes all of the methods and data types employed by a service. Returning metadata about an WCF service allows consumers of a service to easily create clients for the service.

Problem

What is the use and importance of IMetadataExchange in WCF? I have the following app.config file in which I don't use `IMetadataExchange` endpoint, but I am still able to create my proxy client. I have read that if I don't use `IMetadataExchange` endpoint, AddServiceReference will not work because my service does not expose the metadata. How is it working without exposing `IMetadataExchange` endpoint? ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="metaDataBehavior"> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> <services> <service name ="WCFService.Services" behaviorConfiguration="metaDataBehavior"> <host> <baseAddresses> <add baseAddress="http://localhost:8090/Services/"/> </baseAddresses> </host> <endpoint address="" binding="basicHttpBinding" contract="WCFService.IMathOperations"/> </service> </services> </system.serviceModel> </configuration> ```

Original source