WCF Tutorial
www.Learn2Expert.net A new ASP.Net MVC 4, SSIS, Interview Q/A tutorial - Visit - www.Learn2Expert.net
Skip Navigation LinksHomeMetadata Exchange No of Views: 162994

Metadata Exchange

WCF provides rich infrastructure for Exporting, Publishing, retrieving and Importing the metadata. WCF uses the Metadata to describe how to interact with the service endpoint. Using the metadata, client will create the proxy class for the service using SvcUtil.exe

Exporting Service Metadata

It is the process of describing the service endpoint so that client can understand how to use the service.

Publishing Service Metadata

It is the process publishing metadata. It involves converting CLR type and binding information into WSDL or some other low level representation.

Retrieving Service Metadata

It is the process of retrieving the metadata. It uses WS-MetadataExcahge or HTTP protocol for retrieving the metadata. Importing Service Metadata - It is the process of generating the abstract representation of the service using metadata.

Now we are going to focus mainly on publishing metadata. There are two way to publish metadata, either we can use HTTP-GET or through message exchange endpoint. By default service metadata is turn-off due to security reason. WCF metadata infrastructure resides in System.ServiceModel.Description namespace. Service metadata can be used for following purpose

  • Automatically generating the client for consuming service
  • Implementing the service description
  • Updating the binding for a client

Now let us understand the publishing the metadata using HTTP-GET method.


  • Always create the service with Interface->Implementation format, mention the contract in Interface.
  • Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
  • Change the instance mode to per call as default.
  • Always catch exception using try/catch block and throw exception using FaultException < T >.
  • Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.