How do I create a Web Service in Visual Studio.NET using a WSDL file?

19,370

Actually, for WCF, you should not use wsdl.exe - use svcutil.exe instead.

When you use svcutil.exe on a WSDL, you should get a file myservice.cs which contains an interface (the service contract) and quite possibly some data structures, too (data contracts).

Use those to build your service - the service code needs to implement that interface and provide an implementation for those methods defined. That's basically the meat of the service application.

See the Accessing Services Using a WCF Client Proxy for more details - yes I know, the title is about generating WCF clients, but it works for services, too - you just convert the WSDL (and possibly XSD's) into a C# file and implement that interface defined in there.

You should definitely also read the Schema-based Development with WCF that discusses this very topic - generate services and client from schemas/WSDL created ahead of time.

The same guy (Christian Weyer) is also the original author of a Visual Studio plugin to make contract-first development in WCF a lot easier - go grab it on Codeplex - it's totally free, totally with source - go nuts!

Share:
19,370
myermian
Author by

myermian

Updated on June 11, 2022

Comments

  • myermian
    myermian almost 2 years

    I'm trying to use a WSDL Top Down approach to create a Web Service in Visual Studio 2010.

    I used Eclipse's WSDL GUI Editor to generate a WSDL file (CalculatorWSDL.wsdl) which uses the SOAP method for communication.

    I also used wsdl.exe to generate a C# file (Calculator.cs).

    Now, I'm not sure what to do next. How do I actually use the Calculator.cs on the server and/or client?