digging deeper into service stack
TRANSCRIPT
![Page 1: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/1.jpg)
Digging deeper into ServiceStackThere is more than just easy webservices
![Page 2: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/2.jpg)
All the boring stuff you will forget after the slides have passedWho, where, what?
![Page 3: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/3.jpg)
Why am I here…• Stefan Daugaard Poulsen• @cyberzeddk• AP in Computer Science• Developer/Architect at Atea Denmark• Currently working on Atea Tele
• .NET developer since 2002• Silverlight developer back in 2011 with high use of
WCF• “Caught” in a discussion about webservices in
November 2011• Got annoyed by RPC style, code-gen webservices
![Page 4: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/4.jpg)
![Page 5: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/5.jpg)
![Page 6: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/6.jpg)
Is it needed? Does it solve anything?
Why is ServiceStack interresting?
![Page 7: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/7.jpg)
What are bad ideas for webservices• Code-gen• It fails…too often
• Archaic Xml configuration• Distribution, misspelling…or even horrible merges
• Defaults that is bound to make you cry• Why do I need to set values that should be default!
• Fixed serialization• Could be nice to talk to more systems no matter who they are
• RPC style services• Maintenance hell
• Chatty services• Bulk it!
![Page 8: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/8.jpg)
![Page 9: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/9.jpg)
![Page 10: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/10.jpg)
What is this ServiceStack thing• Official subtitle:• Web Services done right, REST services done easy :)
• Simple and model-driven• Endpoint ignorant• Authentication built-in• IoC based• Easy access to HTTP• Fast as lightning• Cross platform• Extendable• Oh!... And clients are in the box
![Page 11: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/11.jpg)
This is where the most wheels are turning in your developmentSeen from the serverside
![Page 12: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/12.jpg)
Gentlemen, start your engines…• IService• Service• And a lot more…
![Page 13: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/13.jpg)
Quick steps• Conventionbased registrations• Throw exceptions and have magic
httpstatuscodes• Strong typed returns• It’s more than CRUD• PATCH etc.
• Restrict access to your services
![Page 14: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/14.jpg)
Endpoint ignorant• JSON• Xml• JSV• CSV• SOAP• 1.1• 1.2
• Custom
![Page 15: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/15.jpg)
![Page 16: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/16.jpg)
What was lost in the ”war”• Funq• OrmLite• ICacheClient• MiniProfiler• Validation• Custom responses• Headers
![Page 17: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/17.jpg)
Funq – it’s almost to easy• It’s dead simple• Fullfills the basic needs• It’s fast• If you don’t like …add an adaptor
![Page 18: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/18.jpg)
OrmLite – why stick to EF or Nhibernate?• Do you really need EF?• Do you trust your developers to know SQL?• Want to get closer to the server?• Pragmatic over academic
![Page 19: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/19.jpg)
Caching – we need more problems?• You added caching so now you have more
problems• Cachekey generation• It’s so darn hard!!!
![Page 20: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/20.jpg)
Profiling – it’s so darn easy• Estimates and guesses leaves you nowhere• Easy to give response to the average Joe• Thank you mr. Saffron and Dixon• Don’t reinvent the wheel!!!
![Page 21: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/21.jpg)
Validation – what everyone hates to repeat• if( request.Id != default(int) )• It’s getting boring!
• Leverage the same validation in several places• Fine grain it where needed
![Page 22: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/22.jpg)
Customized responses• If you want another content type• If you need to return an image• If you want to be a joker?
![Page 23: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/23.jpg)
Custom headers – this is a hard one...NOT!!!• CORS• Please don’t use AddHeader
• If you want to you can do it• Location• …Link?• Not sure you want to go that way ;)
![Page 24: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/24.jpg)
![Page 25: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/25.jpg)
…unless you want to go all JS on me :)Welcome to the clientside
![Page 26: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/26.jpg)
Clients• Client interfaces• IServiceClient• IRestClient• IRestClientAsync
• Implementations• Soap11ServiceClient (only for IServiceClient)• Soap12ServiceClient (only for IServiceClient)• JsonServiceClient(Async)• JsvServiceClient(Async)• XmlServiceClient(Async)
• Or you can hookup to the XSDs or WSDLs as well• Might be handy when delivering services to external partners
![Page 27: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/27.jpg)
If you order now you will get … for only $19.99But that’s not all kids…
![Page 28: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/28.jpg)
It’s a freaking swiss army knife!!!• OrmLite• MySQL• PostgreSQL• Sqlite 32 & Sqlite 64• Firebird• Oracle
• Authentication• MongoDB• Nhibernate• OpenId• RavenDB
• Razor
• Caching• Memcached• Azure
• Protobuf• MessagePack• Logging• NLog• Log4Net• ELMAH• Eventlog
• Swagger
![Page 29: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/29.jpg)
![Page 30: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/30.jpg)
Show off time…Grab your whiskies and smile
![Page 31: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/31.jpg)
I’m in the need for speed!• Fastest JSON serializer• Burning Monk JSON Benchmarks (19/11/2012)
![Page 32: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/32.jpg)
Crossplatform• Supports ASP.NET and HttpListener hosts• Runs on Windows with .NET 3.5 and 4.0• IIS 5/6/7 (uses IHttpHandler)• VS.NET WebDev Server (Cassini)• IIS Express• Console App, Windows Gui, Windows Service
• Linux/OSX with Mono• Apache + mod_mono• Nginx + MonoFastCGI• XSP• Console App
• A demo have been done inside iOS with MonoTouch
![Page 33: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/33.jpg)
Hosting – it can be cheap or really expensive!
Hetzner• 2.67 GHZ• 2GB RAM• 80GB HDD• 4TB Traffic
• €19.90• €238.80
Windows Azure• 1.67 GHZ• 1.75GB RAM• 100GB HDD• 2TB Traffic
• €219.50• €2634
![Page 34: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/34.jpg)
![Page 35: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/35.jpg)
Where do we go next?Well where I am going I don’t need roads!!!
![Page 36: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/36.jpg)
Where is it hidden?• Source: https://github.com/ServiceStack• Wiki:
https://github.com/ServiceStack/ServiceStack/wiki• More docs: http://www.servicestack.net/docs/
• Community resources: https://github.com/ServiceStack/ServiceStack/wiki/Community-Resources
• Links to InfoQ articles: http://www.servicestack.net/mythz_blog/?p=860
![Page 37: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/37.jpg)
Who’s behind this thing…and do I dare use it for production• Main contributor: Demis Bellot (@demisbellot)• Currently creating awesomeness at StackExchange
• It’s been around for a while• First commit Dec 21, 2008• It is well maintained• Currently at version 3.9.37• Jun 6 2012 – 3.9.2• Jan 8 2012 – 3.2.0• Jun 11 2011 – 2.2.0
![Page 38: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/38.jpg)
![Page 39: Digging deeper into service stack](https://reader035.vdocuments.site/reader035/viewer/2022062503/58f194361a28ab45308b4593/html5/thumbnails/39.jpg)
That’s all folks• Twitter: @cyberzeddk• LinkedIn: http://www.linkedin.com/in/cyberzed• Blog: http://cyberzed.dk• Email: [email protected]• GitHub: http://github.com/cyberzed/
• Tutorials will be published soon at Tech.Pro• Book will be started of as an OS project this year
Feel free to contact me with any questions, or if you want me to come talk more about ServiceStack