Click here to Skip to main content
15,891,375 members
Articles / WCF

ServiceContractGenerator vs. ServiceDescriptionImporter

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
15 Dec 2011CPOL1 min read 11.8K   2   2
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)


Written By
Technical Lead
India India
I write software using Microsoft web technologies since 2008. I have successfully delivered software products for Fortune 500 companies and startups.

Microsoft Certified Technologies Specialist - Web Applications Development with Microsoft .NET Framework 4.

Awarded as Microsoft Community Contributor of the year 2011.

Received several awards at various forums and my various articles got listed as "Article of the day" at ASP.NET Microsoft Official Website https://www.asp.net/

Visit My Blog:
https://ramanisandeep.wordpress.com/


Area of Expertise:
C#, ASP.NET, Web Services, WCF, ASP.NET MVC, SQL Server, WEB API, AngularJS, jQuery

Comments and Discussions

 
QuestionGenerate Generics in client code Pin
Pratik Gaikwad6-Mar-16 6:19
Pratik Gaikwad6-Mar-16 6:19 
AnswerRe: Generate Generics in client code Pin
Sandeepkumar Ramani12-Sep-16 20:29
Sandeepkumar Ramani12-Sep-16 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.