This document introduces ServiceStack, an open source web services framework for .NET. It focuses on simplicity, speed and cross-platform support. Key features include convention over configuration, support for multiple data formats including JSON and XML, and a stack of reusable components like ORM and caching libraries. ServiceStack encourages best practices like separating domain models from DTOs and developing coarse-grained, reusable web services.
3. Why ServiceStack
La prima alternativa a WCF, MVC e WebAPI
◦ Focus su semplicità e velocità
◦ Supporto cross-platform con Mono
◦ Convention over Configuration
◦ No XML Config, No Code-gen
◦ POCOs
◦ Incoraggia l’utilizzo delle best practices (DTO)
◦ Write once, support all
◦ XML, JSON, HTML, CSV, JSV
7. Simplicity
◦C# Model-driven development
◦ Definizione delle Web Service API utilizzando DTOs strong-
typed
◦ No Code-gen
◦No Artificial layers or constructs
◦ Completo controllo sugli HTTP Headers e sulla serializzazione
dell’output
◦Endpoint ignorant
◦ C# only, code to interfaces and types not specific formats or
endpoints
◦ C# object IN -> C# object OUT
◦No config required
8. Simplicity - Client
◦Same C# client can call any web service at any endpoint
◦ Generic C# Service Clients: XML, JSON, JSV and
Soap11/Soap12
◦ Provides ErrorCode, ErrorMessage from WebServiceException
9. Speed
◦Built on raw IHttpHandlers
◦No runtime reflection or regular expressions
◦Uses Built-in Funq IOC
◦ Funq is 55x faster than Windsor
◦Fastest JSON, JSV text serializers for .NET
◦ ServiceStack.Text is 3.6x faster DataContractJsonSerializer
◦Includes #1 C# Redis Client
◦ Redis is the fastest in-memory NoSQL database
◦Includes ASP.NET config-free caching providers
◦ Memcached
◦ Redis
◦ In-Memory
◦ FileSystem
10.
11.
12.
13.
14.
15. Encourage Remote Services best practices
◦Influenced by Martin Fowlers Data Transfer Object Pattern
When you're working with a remote interface, such as Remote Facade
(388), each call to it is expensive. As a result you need to reduce the
number of calls, and that means that you need to transfer more data
with each call. One way to do this is to use lots of parameters. However,
this is often awkward to program - indeed, it's often impossible with
languages such as Java that return only a single value.
◦Encourage batch-full, re-usable web services
◦ Discourage chatty, client-specific APIs
◦Importance of a Coarse-grained, well-defined API
◦Simple and flexible serializers with better versioning support
◦Decoupling of message from operation and endpoint
◦Clean separation of DTO from implementation
16. Encourage best code practices
◦Code-First, Code-Only
◦Auto-wired, Built-in IOC
◦Decoupled, develop services independently. Easy add/remove
◦Develop logic in a DDD clean-room
◦Highly testable
◦ Same test can be used for Unit or XML, JSON, SOAP, etc Integration
tests
◦ HttpListener allows for in-memory integration tests (No HTTP
Server reqd.)
17. Fuse C# and HTTP as DRY as possible
◦Develop service using only C# POCO types
◦Same service with no config or code-gen
◦ Callable via REST, RPC POX/J or SOAP endpoints
◦ Callable on any format (XML, JSON, SOAP, JSV, CSV, HTML)
◦via HTTP Accept: or ?format=type. JSONP with ?callback=cb
◦ Can process HTTP File Upload multipart/form-data
◦Strong-typed Request DTO can be populated by:
◦ HTTP GET QueryString
◦ HTTP POST DTO Content-Type (i.e. XML, JSON, etc)
◦ HTTP FORM POST x-www-form-urlencoded
◦Can return any of:
◦ Any DTO object -> serialized to Response Content-Type
◦ HttpResult, HttpError for Customized HTTP response
◦ String
◦ Stream
◦ IStreamWriter
18. Run everywhere in .NET and MONO
◦Supports both ASP.NET and HttpListener hosts:
◦Runs on Windows with .NET 3.5 & 4.0
◦ IIS 5/6/7 (uses IHttpHandler)
◦ VS.NET WebDev server
◦ Console App or Windows GUI
◦ Windows Service
◦Linux/OSX with MONO
◦ Apache + mod_mono
◦ Nginx + MonoFastCGI
◦ XSP
◦ Console App
◦ Haz demo running inside iOS with MonoTouch :)