How to use a WSDL file to create a WCF service (not make a call)

There are good resources out there if you know what to search for. Try "Contract First" and WCF. or "WSDL First" and WCF.

Here is a selection:

  • Basic overview of WSDL-First development with WCF and SvcUtil.exe.
  • WSCF - A free add-in to Visual Studio enabling Contract-First design with WCF
    • Introduction to WSCF
    • A walkthrough of using WSCF
    • The WSCF project page on CodePlex (WSCF is now open source)
  • Article on how to design "WCF-Friendly" WSDL

Using svcutil, you can create interfaces and classes (data contracts) from the WSDL.

svcutil your.wsdl (or svcutil your.wsdl /l:vb if you want Visual Basic)

This will create a file called "your.cs" in C# (or "your.vb" in VB.NET) which contains all the necessary items.

Now, you need to create a class "MyService" which will implement the service interface (IServiceInterface) - or the several service interfaces - and this is your server instance.

Now a class by itself doesn't really help yet - you'll need to host the service somewhere. You need to either create your own ServiceHost instance which hosts the service, configure endpoints and so forth - or you can host your service inside IIS.

Tags:

Wcf

Wsdl