Service-Oriented Architecture is a set of services, where each service is a standalone loosely coupled unit. Each service receives one or more requests and provides responses to these requests using defined interface. SOA allows effective and flexible communication between systems regardless of technology they are built with.
ServiceStack is an open-source .NET and Mono REST Web Services framework, which provides simple, cleaner POCO-driven way of creating web services. Additional information why you should choose ServiceStack can be found here.
OpenAccess ORM and ServiceStack
It is very easy to integrate OpenAccess ORM as a persistence solution and use it from a ServiceStack web service.
Let’s start with the setup of ServiceStack, you could use the NuGet package manager to do that:
Before moving to the implementation of the service we will register it together with its dependencies. The following code snippet should be added under the Global.asax.cs file:
There are three parts in a ServiceStack service: Request DTO, Response DTO and the service implementation. In this blog post we will read category data filtered based on its identity. This means we need an appropriate request DTO:
The service will return the following response:
Note the name of the response DTO. It is constructed by appending Response to the request DTO name. This is the convention used by ServiceStack. To support automatic exception handling a ResponseStatus property is added to the response DTO class.
And here is the implementation of the service itself:
If everything is configured correctly, you could run the service and go to http://[server_uri]/get-category/1 to see your OpenAccess ORM ServiceStack web service in action.
Build automation is important part of software development. It encompasses many tasks – build integration, unit testing, code analysis and deployment. The goal is to automate the repetitive steps, to establish consistency and remove error-prone tasks.
The build tools are programs which organize the software builds by automating the build processes. Among the widely-used build tools in the .NET world are MS Build and NAnt. NAnt is an xml-based open-source build automation tool. This section describes the NAnt fundamentals.
OpenAccess ORM and NAnt
In this blog post I will demonstrate how to integrate OpenAccess ORM and NAnt. There are a few important steps that need to be implemented in order to automate an OpenAccess domain model using NAnt.
The NAnt build definition includes several targets which will be used to automate the build process for the given OpenAccess ORM domain model. A target is a set of tasks which are executable piece of code.
Clean target – this is an optional target. It is used to clean up the build folder;
Build target – builds the source files, embeds the rlinq file as a resource, defines the needed references and copies the necessary OA assemblies;
Enhance target – runs the OpenAccess ORM Enhancer over the built project using the rlinq file as a metadata source;
Note the exec task’s arguments listed above. They are providing the enhancer with the built assembly, which will be enhanced, and its metadata source. The metadata source will be used to obtain the metadata container which describes the domain model metadata. In this example the domain model is using an xml mapping. There can be scenarios where the model is defined using attributes or fluent mapping. It is possible to combine all of the mapping types in one OpenAccess ORM project.
WHAT IS A COOKIE?
A cookie is a small fragment of text that websites send to the browser and that are stored in the user’s device, such as their personal computer, mobile telephone, tablet, etc. These files are used by the website to remember information about the visit, such as language preferences and other options, while helps to set things up for their next visit and make the website more useful by personalising its content. Cookies play a very important role improving the experience of using the website.