GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.servicestack.net — Creating a WebService from scratch Creating a WebService from scratchStep 1: Create an applicationServiceStack can be hosted in a few ways: console application, windows service, ASP.NET Web Form or MVC in IIS, etc. For this tutorial, an empty ASP.NET Web Application (non MVC) is assumed. Step 2: Install ServiceStackTo install ServiceStack into your application, you have two options to get the binaries:
Tip You can find an explanation about all NuGet packages which ServiceStack offers here. The package above only adds the binaries, but there also exist some packages which add the required configurations etc Register ServiceStack HandlerAfter you've added the binaries, you need to register ServiceStack in If you want to host ServiceStack at root path (
Tip If you want to host your webservice on a custom path to avoid conflicts with another web framework (eg ASP.Net MVC), see Run ServiceStack side-by-side with another web framework WARNING Due to limitations in IIS 6 - host ServiceStack at a /custompath which must end with Step 3: Create your first webserviceIf Each service in ServiceStack consists of three parts:
That's the core philosophy in ServiceStack. Each service has a strongly-typed, code-first (normal POCOs) Request DTO and response DTO. You can read a detailed explanation what advantages exist if you're using DTOs in the ReadMe or in [Why should I use ServiceStack?] (/why-servicestack).
Step 4: Registering your web services and starting your applicationThe final step is to configure setup to tell ServiceStack where to find your web services. To do that, add this code to your
Done! You now have a working application :) As you can see, you have created an Disable WebApi from the default MVC4 VS.NET templateIf you are using MVC4 then you need to comment line in global.asax.cs to disable WebApi
ServiceStack is now Ready!Now that you have a working Web Service lets see what ServiceStack does for you out of the box: If everything is configured correctly you can go to
Tip In the screenshot the root path is Let's access the HelloWorld service you created in your browser, so write the following URL in your address bar:
As you can see after clicking on this link, ServiceStack also contains a HTML response format, which makes the XML/Json (...) output human-readable. To change the return format to Json, simply add TroubleshootingIf you happen to generate requests from the wsdls with a tool like soapUI you may end up with an incorrectly generated request like this:
You can resolve this issue by adding the following line to your AssemblyInfo file
Rebuild and regenerate the request from the updated wsdl. You should get a correct request this time.
Explore ServiceStack Documented DemoThe EmailContacts solution is a new guidance available that walks through the recommended setup and physical layout structure of typical medium-sized ServiceStack projects, including complete documentation of how to create the solution from scratch, whilst explaining all the ServiceStack features it makes use of along the way. Community Resources
On This Page
|
| You are visitor 01402877 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |