Setting up a ServiceStack Service
- Part 1 - Setting up the Virtual Machine and nginx
- Part 2 - Setting up new Website and Domain on nginx
- Part 3 - Setting up Mono on nginx
- Part 4 - Setting up a NancyFX website
- Part 5 - Setting up a ServiceStack web service
Time to setup a ServiceStack service!
ServiceStack is great, specially when you need to support .NET 3.5 and don't have the pleasure of being able to use .NET 4.0/4.5, you're not limited to .NET 3.5, ServiceStack works great with .NET 4.0/4.5 as well!
God forbid we get subjected to having to use WCF...
Setting this up should be super easy, we will use all the same settings as NancyFX, the only difference is we will be running ServiceStack instead.
The ServiceStack team take real care to ensure that it works on Mono, enough so that their website; http://www.servicestack.net, runs on Linux!
Creating the Sample Project
One of the great things about ServiceStack is it has a bunch of awesome examples. Head on over to https://github.com/ServiceStack/ServiceStack.Examples and download the samples. Either by downloading the repository, or cloning it.
After downloading the ServiceStack Examples, navigate to
src and open the
Running this project we should end up with a small Service Stack sample website like so:
Quick local test
Navigating to the URL;
http://localhost:62577/servicestack/metadata we should get the nice meta data screen:
And navigating to the URL:
We end up with a response:
We do need to make one minor change. In the root project of the folder, rename the
default.htm file to
index.html. This is only so we don't need to modify nginx to look for the default file
default.htm :) #lazyme
Lets deploy it!
So like the Nancy project, we can publish the project to a folder. The good thing about this sample is it doesn't need any database or anything like that. It's just a straight website with a Hello World service.
Once deployed we should end up with the ServiceStack site again!
Navigating to the metadata page we end up with the same screen we had locally!
And navigating to the test URL we end up with the fancy ServiceStack response!
Hello, with love from nginx!
That's it, using the best web frameworks, NancyFX and ServiceStack, is super duper happy path easy with Mono!
:)comments powered by Disqus