Click here to Skip to main content
13,446,770 members (40,240 online)
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 3 Dec 2015

WSDL Equivalent for Rest API

, 3 Dec 2015
Rate this:
Please Sign up or sign in to vote.
Generate User Interface for Web API that lists down all the http services without writing a single line of code


One feature from legacy web services that we would miss in this modern http services days is WSDL. It is the interface to client that:

  1. Lists down all the HTTP operations that can be performed on a Service
  2. Describes input and output parameter data types to invoke the operations

Though, Rest API services are very efficient, it is not self described. Client applications that consume the rest service have no clue about input and output data format unless explicit documentation is provided.


Swagger comes to the rescue here. It provides a nice UI listing all the http endpoints and with sample of input and output parameters.

Official site -

Let's show you the steps.

  1. Create a Web API project in VS. Create a new controller named 'Customer' and paste the below code.
     public class CustomerController : ApiController
            static List<Customer> Customers = new List<Customer>();
            static int counter = 0;
            // GET api/customer
            public IEnumerable<Customer> Get()
                return Customers;
            // GET api/customer/5
            public Customer Get(int id)
                return Customers.Where(c => c.Id == id).FirstOrDefault();
            // POST api/customer
            public void Post([FromBody]string value)
                Customer c = new Customer() { Id = ++counter, Name = value };
            // PUT api/customer/5
            public void Put(int id, [FromBody]string value)
                Customers.Where(c => c.Id == id).Select(c => { c.Name = value; return c; }).ToList();
            // DELETE api/customer/5
            public void Delete(int id)
                Customers.Remove(Customers.Where(c => c.Id == id).FirstOrDefault());            
  2. Install Swagger through Nuget package manager console:
    PM> Install-Package Swashbuckle

    FYI. This installation will create a file - SwaggerConfig under App_Start.


  3. Run the project and type swagger at end of the url in browser.

    You should be seeing this screen - Swagger UI. Click on 'expand operations' to view all the http operations in a detailed way.


What this Swagger UI is Capable Of ?

  1. All type of Http requests - GET, POST, PUT and DELETE can be triggered from this UI. Input proper data and click 'Try it now' button. Response will be shown right below. Something like Postman in Chrome, Fiddler.
  2. Model Schema - Output model structure which supports both XML and JSON format.
  3. Response content type is editable.
  4. Response includes a lot of information like response data, code and headers.
  5. Shows cURL commands for the requests fired. cURL is a command line utility to create http requests using commands that support all features that can done through browser. First, cURL needs to be installed to use this.

What are you waiting for? Download the attached project and have fun!!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kanivalan Raju
Software Developer (Senior) Microsoft Global Delivery
India India
Yet another software developer who works on various Microsoft and Web technologies but curious to try something beyond an usual

You may also be interested in...


Comments and Discussions

QuestionGood stuff Pin
Member 125966476-Sep-16 0:16
memberMember 125966476-Sep-16 0:16 
QuestionWhat about an existing ApiExplorer? Pin
Easked3-Dec-15 22:12
memberEasked3-Dec-15 22:12 
AnswerRe: What about an existing ApiExplorer? Pin
William E. Kempf7-Dec-15 3:17
memberWilliam E. Kempf7-Dec-15 3:17 
GeneralRe: What about an existing ApiExplorer? Pin
Easked8-Dec-15 22:12
memberEasked8-Dec-15 22:12 
QuestionThis is cool thing for developer to troubleshoot Pin
santosh poojari3-Dec-15 18:50
membersantosh poojari3-Dec-15 18:50 
SuggestionYou've got some broken links Pin
Paul Tait3-Dec-15 15:06
memberPaul Tait3-Dec-15 15:06 
GeneralRe: You've got some broken links Pin
Kanivalan Raju3-Dec-15 17:31
memberKanivalan Raju3-Dec-15 17:31 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04-2016 | 2.8.180318.2 | Last Updated 3 Dec 2015
Article Copyright 2015 by Kanivalan Raju
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid