Professional Documents
Culture Documents
Windows Communication
Foundation 3.5
Rob Windsor
ObjectSharp Consulting
rwindsor@objectsharp.com
Me.About
Client Service
A B C
C B A Message A B C
objectsharp.com/artists/Flaming+Hammer/HitMe
objectsharp.com/artists/Northwind/Overdone
objectsharp.com/artists/{artist}/{album}
objectsharp.com/artists/Flaming+Hammer?album=HitMe
objectsharp.com/artists/Northwind?album=Overdone
objectsharp.com/astists/{artist}?album={album}
Modeling a URI in .NET 3.5
System.UriTemplate
Type for modeling URI to application semantics
Can “bind” data to a template, output a URI
Can “match” a URI to a template, retrieve data
System.UriTemplateMatch
Returned from UriTemplate “match” operations
Can get relative paths and wildcard segments
System.UriTemplateTable
For “binding” a URI to a group of UriTemplates
Roundtrip Data in a URI
[OperationContract]
[WebGet(UriTemplate=“/Image/{artist}/{album}”)]
Stream GetAlbumImage(String artist, String album);
[OperationContract]
[WebGet(UriTemplate=“/Image?name={artist})]
Stream GetMainImage(String artist);
HTTP Verbs in WCF Contracts
All HTTP verbs are first class citizens
GET, POST, PUT, etc.
“View It” vs “Do It” separation mimics web
[OperationContract]
[WebGet(UriTemplate=“/Image/{bandName}/{album}”)]
Stream GetAlbumImage(String bandName, String album);
[OperationContract]
[WebInvoke(METHOD=“PUT”)] // {PUT, POST, DELETE}
void AddAlbum(AlbumInfo albumInfo);
Data Formats and the Web
HTTP headers can indicate
Accepted data formats (Request)
The format of the returned data (Response)
Common header names:
Accept (Request), Content-Type (Response)
Small sampling of varieties:
text/html, text/css,
image/gif, image/jpeg,
application/atom+xml, application/json,
video/mp4
Specifying Data Format in WCF
WebOperationContext.Current provides access to
incoming request headers
Can also set outgoing response headers
Some are shortcut for easier use
[ServiceKnownType(typeof(Atom10FeedFormatter))]
[ServiceKnownType(typeof(Rss20FeedFormatter))]
[ServiceContract]
interface IAlbumSyndication {
[OperationContract]
[WebGet(UriTemplate=“Images/{format}")]
SyndicationFeedFormatter<SyndicationFeed>
Feed(String format);
}
Syndication with PictureServices
Web Centric Features in WCF 3.5
Built on WCF
extensibility points
from .NET 3.0
Resources
Microsoft WCF Community Site
http://wcf.netfx3.com/
PictureServices Samples
http://www.cloudsamples.net/pictureservices/
The EndPoint on Channel 9
http://channel9.msdn.com/shows/The_EndPoint
Justin Smith’s Blog
http://blogs.msdn.com/justinjsmith/
Steve Maine’s Blog
http://hyperthink.net/blog/
Getting Started with WCF
http://msdn2.microsoft.com/en-us/vbasic/bb736015.aspx