Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 435
myermian Avatar asked Feb 27 '23 20:02

myermian


1 Answers

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!

like image 93
marc_s Avatar answered Mar 05 '23 15:03

marc_s