ServiceContractGenerator vs ServiceDescriptionImporter

Recently, I have worked with WCF. During this , I have developed one tool that help us to run any web service (.asmx) and wcf service (.svc) by just using URL of it. It was totally dynamic process. In this process, I have learn how to fetch method list , parameter names and how to invoke method dynamically. During this process I came across the terms called ServiceDescriptionImporter and ServiceContractGenerator. So I feel that I should share what these terms means and difference between them with my readers. so here it goes…

ServiceDescriptionImporter :

The ServiceDescriptionImporter class allows you to easily import the 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.


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

ServiceContractGenerator vs ServiceDescriptionImporter:

–>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.

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

–> ServiceDescriptionImporter uses the asmx client infrastructure (System.Web.Services.Protocols.SoapHttpClientProtocol and friends).

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

Hope this will help !!!


4 thoughts on “ServiceContractGenerator vs ServiceDescriptionImporter

  1. Hello Ramani,

    Would you mind sharing your code?
    I’d really appreciate it.

    Greetings from Turkey,

  2. Romani,

    I believe the code that Ozcan is referring to is the source code of the tool you wrote that will run web services/wcf dynamically. I’m also interested in seeing the code. I’ve been trying to write a similar tool but to no avail. Hope you could share your code and thanks in advance.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s