Jul 242012
Share...Tweet about this on TwitterShare on FacebookShare on Google+Share on StumbleUponShare on LinkedInPin on PinterestShare on TumblrShare on RedditDigg this

Just wondering how many different ways are there for creating Web Services (of any kind) in the Microsoft.NET stack.

ASP.NET Web Services

Introduced from the beginning of the Microsoft.NET. ASP.NET Web Services technology has given a very easy way of creating Services within the Microsoft.NET stack. Even being so easy to implement, ASP.NET Web Services are good only in simple scenarios. ASP.NET Web Services are mainly built around SOAP, but there is a support as well for JSON and XML messages. It’s a great start if you want to expose some functionality in an easy way but without pretending too much when it comes to the interoperability.

Web Services Enhancements (WSE)

WSE is an add-on to the Microsoft .NET Framework which includes a set of classes that implement additional WS-* web service specifications chiefly in areas such as security, reliable messaging, and sending attachments.[1] Web services are business logic components which provide functionality via the Internet using standard protocols such as HTTP. Web services communicate via either SOAP or REST messages. WSE provides extensions to the SOAP protocol and allows the definition of custom security, reliable messaging, policy, etc. Developers can add these capabilities at design time using code or at deployment time through the use of a policy file.

WSE perfectly extends the control and adds support for standards within the ASP.NET Web Services stack.

Windows Communication Foundation

Windows Communication Foundation has been introduced with the Microsoft.NET v3. WCF is Microsoft’s unified programming model and runtime for building Web services applications with managed code. It extends the .NET Framework with functionality to build secure, reliable, and transacted Web services that interoperate across platforms. WCF is built from the ground-up to combine and extend the capabilities of existing Microsoft distributed systems technologies, including Enterprise Services, System.Messaging, .NET Remoting, ASMX, and WSE, to deliver a unified development experience based on Web services.

WCF REST Starter Kit

Ever since the release of WCF 3.5, Microsoft has been working hard to make the process of building and consuming RESTful services even easier on the .NET platform. One of the results of that effort is a new suite of helper classes, extension methods, and Visual Studio project templates packaged into what’s called the WCF REST Starter Kit. Today, the WCF REST Starter Kit can be downloaded from CodePlex but many of its features may find their way into future versions of the official .NET framework. Unfortunately WCF REST Starter kit ceased to exist and ASP.NET Web API should be used instead.


ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.

Even though ASP.NET MVC is not specifically designed to be a technology dedicated for building Web Services, ASP.NET MVC controllers can directly return objects and collections, without rendering a view, which makes it quite appealing for creating REST like API.


ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. It is a fresh framework that is part of the ASP.NET MVC 4, and at the time of writing hasn’t been released yet officially. The ASP.NET Web API should simplify and enhance the RESTful service creation within the Mirocrosoft.NET stack and leverage the complexity that WCF currently exposes.

WCF Data Services

WCF Data Services (formerly known as “ADO.NET Data Services”) is a component of the .NET Framework that enables you to create services that use the Open Data Protocol (OData) to expose and consume data over the Web or intranet by using the semantics of representational state transfer (REST). OData exposes data as resources that are addressable by URIs. Data is accessed and changed by using standard HTTP verbs of GET, PUT, POST, and DELETE. OData uses the entity-relationship conventions of the Entity Data Model to expose resources as sets of entities that are related by associations.

HTTP Handlers and HTTP Modules

An HTTP handler is the process (frequently referred to as the “endpoint”) that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. You can create your own HTTP handlers that render custom output to the browser.

An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request.

Therefore, ASP.NET provides a low-level request/response API that enables developers to use .NET Framework classes to service incoming HTTP requests. Developers accomplish this by authoring classes that support the System.Web.IHTTPHandler interface and implement the ProcessRequest() method. Handlers are often useful when the services provided by the high-level page framework abstraction are not required for processing the HTTP request. Common uses of handlers include filters and CGI-like applications, especially those that return binary data.

Each incoming HTTP request received by ASP.NET is ultimately processed by a specific instance of a class that implements IHTTPHandler. IHttpHandlerFactory provides the infrastructure that handles the actual resolution of URL requests to IHttpHandler instances. In addition to the default IHttpHandlerFactory classes provided by ASP.NET, developers can optionally create and register factories to support rich request resolution and activation scenarios.

Follow the link for more information and examples: http://msdn.microsoft.com/en-us/library/bb398986(v=vs.100).aspx

Open Source Technologies

As you may see above, Microsoft.NET is very often changing the technologies and this is not really easy to follow. Especially when the WCF has been introduced, in the beginning it looked like this would solve all the problems, but that was simply not the case. WCF is a solid technology that supports a great deal of functionality, but it is built around SOAP, which makes it great for the Enterprise usage. The main critics around WCF is it’s complexity. Usually to configure a WCF Service could be pretty much complex.

For sure you are wondering if there are alternatives to all this. The answer is YES.


Service Stack is a high-performance .NET web services framework (including a number of high-performance sub-components) that simplifies the development of XML, JSON, JSV and WCF SOAP Web Services. For more info check out servicestack.net.
ServiceStack has a large number of components, and it has its own “ecosystem”. Please check the http://www.servicestack.net/


By focusing development around resources and HTTP methods, OpenRasta simplifies the creation of ReST-friendly interfaces. Developed to respect modern development practices, coming prepackaged with an inversion of control container, and enforcing the use of dependency injection throughout the framework, OpenRasta is a framework implementing an architectural pattern close to Model-View-Controller, called Resource-Codec-Handler.

OpenRasta also supports advanced HTTP features such as content negotiation, digest access authentication and full control of response codes sent back to a client[2].

Hosting of an application built on OpenRasta is available through ASP.NET, in-memory, in-process through Windows’ HTTP APIs, or through any other environment able to receive HTTP requests, as the framework itself has no dependency on ASP.NET. Please check out http://openrasta.org/


Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono. The goal of the framework is to stay out of the way as much as possible and offer a super-duper-happy-path to all interactions.

Nancy is designed to handle DELETE, GET, HEAD, OPTIONS, POST, PUT and PATCH requests and provides a simple, elegant, Domain Specific Language (DSL) for returning a response with just a couple of keystrokes, leaving you with more time to focus on the important bits.. your code and your application. Check the web site: http://nancyfx.org/


Kayak is a lightweight HTTP server for the CLR, and the Kayak Framework is a utility for mapping HTTP requests to C# method invocations. With Kayak, you can skip the bulk, hassle, and overhead of IIS and ASP.NET. Kayak enables you to do more with less syntax, and is easy to configure to work in any way you care to dream up.


OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools.

OWIN defines a single anonymous delegate signature, and therefore introduces no dependencies; there is no OWIN source code. Check the Owin web site at: http://owin.org/


RestCake is a C# library for creating REST services without WCF. WCF has many pain points:
– Date formatting is horrible (DataContractJsonSerializer)
– Can’t serialize anonymous types
– Too much configuration
– Can’t handle cycles in object graphs
– No global error handling
The examples and documentation are online at http://restcake.net, which is simply the published AddressBook.Web and AddressBook.Services projects from the source.


Spring adds the ability to perform dependency injection on standard asmx web services. Spring’s .NET Web Services support also allows you to export a ‘plain CLR object’ as a .NET web service By “plain CLR object” we mean classes that do not contain infrastructure specific attributes, such as WebMethod. Spring provides the functionality to create the web service proxy dynamically at runtime. On both the server and client side, you can apply AOP advice to add behavior such as logging, exception handling, etc. that is not easily encapsulated within an inheritance hierarchy across the application.

The examples and documentation are online at http://www.springframework.net/doc-latest/reference/html/spring-services.html.


The content of this post is mainly taken from the official web sites of the product mentioned here, so all credits to the people who actually wrote it. I just wanted to illustrate how dynamic and complex is the world (and therefore adventurous and exiting:)) of web services in the Microsoft.NET.
Personally I’ve only read about the open source alternatives and thinking on implementing some applications with it currently, but haven’t yet used it in any of the production system I am currently working on.
If you think that I forgot something please let me know (comments below), and I will be happy to include it to complete this list.

    Share...Tweet about this on TwitterShare on FacebookShare on Google+Share on StumbleUponShare on LinkedInPin on PinterestShare on TumblrShare on RedditDigg this

    I'm a Software Developer and Solution Architect interested in Software Development, Object-Oriented Design and Software Architecture all this especially bound to the Microsoft.NET platform.Feel free to contact me or know more in the about section

      5 Responses to “What technology for building Web Services in Microsoft.NET?”

    1. Hi Zoran,
      i have a problem i need to create a web service in ASP.net , which should accept data through HTTP POST. do you have any idea about it.
      What should i do that the data i m sending through code can reach web service and that web service will save the data to database.

      link to web service –
      Thanks and regards,

      • Hi Javed,
        Try adding this in your web.config

        <add name=”HttpGet”/>
        <add name=”HttpPost”/>
        a similar question has been asked previously on slashdot, follow this link


    2. Nice article. I feel however, that you left of ASP.NET MVC (without WEB API) as a natural way of building web services. This is how we’ve been doing it for a while now, but of course we will look at doing it with Web API now that it is here.

    Leave a Reply

    berdarsebastian badamo_jamila@mailxu.com