The Spring.NET Web Service Exporter Part 1 – Introduction

Spring.NET is a .NET port of the popular Java Spring framework. It simplifies implementation and maintenance of large applications by:

  • Handling common tasks like transaction handling, service lookups and object pooling through DI (Dependency Injection) and proxy-based AOP (Aspect-Oriented Programming) managed by configuration files instead of code implementation
  • Reducing boilerplate code by offering inheritable classes, for example for ADO access

One of the tasks that moves application setup from the actual code to the configuration file is the web service exporter. In the traditional .NET world, ASMX webservices are created by decorating the class and methods you want to expose with specific attributes. Here is the standard Hello World example of a traditional ASMX Web Service:

 using System; using System.Data; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.ComponentModel; namespace Qat.Demo { /// /// Your basic Hello-World Service as generated by Visual Studio. /// [WebService(Namespace = "http://QAT/services/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class TestService2 : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } } } 

If it is that simple, what advantages does the Spring.NET Web Service Exporter have? Two important reasons:

  • It cleanly seperates the implementation of business logic (your code) from the infrastructure configuration (which methods get exposed how and where). You can expose the same object in multiple ways (or remove the exposure) without ever touching the object code. For a small application this may not be a big deal but a clean seperation of application aspects makes code management in large enterprise applicatons a lot easier and also more flexible.
  • It enables the standard DI (Dependency Injection) mechanisms Spring.NET offers. This allows “wiring” your objects together via the configuration thereby eliminating the code for looking up and instantiating dependencies as well as improving performance by letting the Spring.NET framework manage object pools (often, there will be only a single instance servicing all requests).

Stay tuned for details on how to export an object as a web service using Spring.NET.

Anke


.NET, Web Services

Written by: |

Connect with us: