Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / WCF

ServiceContractGenerator vs. ServiceDescriptionImporter

0.00/5 (No votes)
15 Dec 2011CPOL1 min read 12.1K  
Differences between ServiceDescriptionImporter and ServiceContractGenerator

Recently, I worked with WCF. During that time, I developed a tool that help us run any web service (.asmx) and WCF service (.svc) by just using the URL. It was a totally dynamic process. In this process, I learned how to fetch a method list, parameter names, and how to invoke a method dynamically. During this process, I came across terms like ServiceDescriptionImporter and ServiceContractGenerator. So I feel that I should share what these terms mean and the differences between them. So here it goes…

ServiceDescriptionImporter

The ServiceDescriptionImporter class allows you to easily import information contained in a WSDL description into a System.CodeDom.CodeCompileUnit object.

By adjusting the value of the Style parameter, you can instruct a ServiceDescriptionImporter instance either to generate a client proxy class that provides the functionality of the Web service by transparently calling it, or to generate an abstract class that encapsulates the functionality of the Web Service without implementing it.

The code in the resulting CodeCompileUnit object can then either be called directly or exported in the language of your choice.

ServiceContractGenerator

The System.ServiceModel.Description.ServiceContractGenerator type generates service contract code and binding configurations from System.ServiceModel.Description.ServiceEndpoint description objects.

ServiceContractGenerator vs ServiceDescriptionImporter

ServiceContractGenerator is the WCF equivalent, for the “Add Service Reference” dialog in VS and the “svcutil.exe” tool in the SDK.

ServiceContractGenerator uses the WCF client infrastructure (System.ServiceModel.ClientBase and friends).

  • ServiceDescriptionImporter is the class that is used by the “Add Web Reference” dialog in VS and the “wsdl.exe” tool in the SDK to generate “ASMX” style client web service proxies.
  • ServiceDescriptionImporter uses the ASMX client infrastructure (System.Web.Services.Protocols.SoapHttpClientProtocol and friends).

Hope this helps!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)