Free Sample
+ Collection

ServiceStack 4 Cookbook

Kyle Hodgson, Darren Reid

Over 70 recipes to create web services, build message-based apps, and work with object-relational mapping
RRP $29.99
RRP $49.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783986569
Paperback444 pages

About This Book

  • Create fast, testable, maintainable web APIs using the fully-featured framework in .NET
  • Integrate ServiceStack to add speed and simplicity to your web applications
  • Step-by-step recipes that focus on solving real-world problems using ServiceStack

Who This Book Is For

If you are a .NET developer who is looking for a simpler way to build services, this is the book for you. It will show you how to write fast, maintainable APIs that are a pleasure to use and maintain starting from the database to the client and everything in-between.

Table of Contents

Chapter 1: Configuration and Routing
Up and running with ServiceStack
Routing using data transfer object attributes
Isolating web service routes from a web application
Common ServiceStack plugins
Writing a custom audit plugin
Adding Routes via the API
Structuring your project to avoid dependency issues
Managing dependencies with Funq and Inversion of Control (IoC)
Sharing and accessing configuration and common functionality using Funq IoC
Chapter 2: Services and Data Transfer Objects
Creating a basic create/read/update/delete service
Splitting HTTP request methods
Hosting services from different assemblies
Utilizing the original HTTP request
Overriding serialization of request object types
Creating a simple admin service
Intercepting requests and responses using attributes
Making a basic proxy for existing web services
Wrapping multiple existing services and exposing them through ServiceStack
Chapter 3: Testing and Logging
Unit testing ServiceStack applications
Integration testing with the ServiceStack C# client
Functional contract testing ServiceStack services
Accessing the request-and-response object with the JsonServiceClient
Continuous Integration with TeamCity and self-hosted services
Logging with a choice of frameworks
Writing a logger to monitor exceptions via e-mail
Chapter 4: Object Relational Mapping (OrmLite)
Modeling your database with types and attributes
Using and accessing OrmLite
Using OrmLite filters to create audit functionality
CRUD and other common operations
Utilizing stored procedures using OrmLite
Mapping custom queries to POCOs
Starting with an existing database with OrmLite and T4 templates
Working with Entity Framework and ServiceStack
Chapter 5: HTML and Form Data
Getting started with ServiceStack and Razor templates
Using Markdown for website content
Handling file uploads and streaming data from services
Overriding Razor views or templates using attributes
Creating and displaying a login and registration page based on authentication
Submitting a form to a service and handling server-side validation on an HTML client
Chapter 6: Filters and Validators
Creating static validation rules using fluent syntax
Returning meaningful HTTP error messages
Adding custom headers via the response filter
Restricting file uploads by type using filters
Creating a user-configurable HTTP callback service using a response filter
Applying a rate limit to a web service endpoint using request filter
Restrict user actions by session details using a validator
Common HTTP status codes
Chapter 7: Security and Authentication
Getting started with authentication, sessions, registration, and user repositories
Getting started with Twitter authentication
Getting started with Google authentication

Getting started with Facebook authentication
Using multiple authentication providers and persisting a user's preferred profile image
Handling password resets for credential-based authentication
Accessing Windows identity information from ServiceStack for an intranet application
Validating password complexity with a custom registration validator
Migrating users from another system by overriding ServiceStack's credential-based authentication
Writing your own OpenID authentication provider
Chapter 8: Working with Redis
Getting started with ServiceStack.Redis
Using Redis as a cache with the ServiceStack client
Using ServiceStack.Redis for publish/subscribe
Using the ServiceStack.Redis client to access a Redis list
Using Redis hash data structures in ServiceStack
Using Redis Set data structures in ServiceStack
Using typed data structures with ServiceStack and Redis
Scripting Redis with Lua
Chapter 9: Integrating with Other Technologies
Integrating with ServiceStack using the C# client and Native Types
Using ServiceStack with WebForms applications
Using ServiceStack with ASP.NET/MVC applications
Broadcasting ServiceStack services with SignalR hubs
Using ServiceStack with MongoDB
Using ServiceStack with Elasticsearch
Working with ServiceStack and AngularJS resources

What You Will Learn

  • Quickly create fast, testable, and maintainable web services with ServiceStack
  • Integrate ServiceStack with existing ASP.NET frameworks such as MVC and SignalR
  • Render HTML using Razor and MarkDown with your ServiceStack services
  • Implement unit and integration testing for your web API to enhance quality and compatibility
  • Work with your SQL database of choice using ServiceStack's ORM, OrmLite
  • Leverage the speed of Redis to scale your web API

In Detail

Building web services is a complex task as every language and framework has its own architecture, which is not easy to analyze. ServiceStack makes it easy to create web services and build applications.

This book covers a wide range of topics from simple development and initial setup using the ServiceStack framework to more advanced concepts such as integration with other popular .NET frameworks. It will show you how to build your services and will also enable you to ensure your web API's quality with step-by-step recipes that show you powerful unit testing and integration testing patterns. You will also learn how to access your SQL database with speed and simplicity using ServiceStack's object-relational mapping framework, OrmLite.


Read More

Recommended for You