MIX08-Building Applications and Services with .NET Framework 3.5

Using new features in .NET 3.5 Framework. blogs.msdn.com/justinsmith

IMAGE_00090

IMAGE_00091

 

What in .NET 3.5 for services:

 

  • The New HTTP Programming model:
  • New support JSON Services
  • Syndication in .NET 3.5

Service Stack Evolution

-Sockets->HttpListener->ASP.net->ASMX->WCF

WCF

one stop shop for services

Myth:WCF is only for enterprise services

Reality:WCF gets around(enterprise and web)

.NET 3.5 WCF web-centric upgrades:

  •    Make REST a 1st class citizenish
  •    Embrace SOAP-less representations
  •      JSON messaging capabilities
  •      Simple working with POX
  •     RSS & Atom syndication support

Run in partial trust (hosting) cool!

Promote web concepts to top status by simplifying the (mapping URIs to application logic, working with HTTP methods and working with Response codes & HTTP Headers)

Support for SOAP/RPC & REST from one or same application.

 

.NET 3.5 additions:

System.UriTemplate

  •    Type for modeling URI to app semantics
  •     Bind Data to a template, output to URI
  •    Match a URI to a template, retrieve data

System.UriTemplateMatch

  •     Returned from UriTemplate "match"
  •    Get relative paths

System.UriTemplateTable

 

Simple URI-to-application mapping -Defaults to query string parameters

 

Http verbs in WCF Contracts

  •    All HTTP GET POST PUT DELETE
  •    View it vs Do it separation mimics web

Specify Data Format in WCF:

WebOperationContext.Current provides access to incoming request headers

  • Can also set outgoing response headers

Bindings and ServiceHosts:

WebHttpBinding and WebServiceHost

  • Use WebServiceHost/Factory in most cases

WebHttpBinding endpoint on a ServiceHost

  • Add webhttpBehavior to the endpoint

Interpretive dance of solution for DEMO.

Cassini for services. Sounds fun.

How to reverse a string demo. *you need to know this if you want a job at Microsoft.

public string someMethod(string, input)

{

char[] chars = input.ToCharArray();

Array.Reverse(chars);

return new string(chars);

}

Go ahead and cheat. its ok.

0 config setup. Service host holds your config info.

use imperative 'approach"or web.config is by default.

 

JSON-centric Types:

  • JsonReaderWriterFactory

  -creates XmlDictionaryReader/Writer objects

  • DataContractJsonSerializer

  -Bridges objects & JSON

JSON messaging:

  Set requestsFormat/ ResponseFormat

WebHttpBehavior to endpoint

Intergrates with ASP.net AJAX

  WebScriptEnablingBehavior to endpoint

                      or

Use WebScriptServiceHost/Factory for automatic endpoint creation (0 config)

 

I have got to get working on this.

 

No Comments