So I'm reading RESTful Web Services and I got inspired. Sounds like a great way to expose data on the web.
So I fire up Visual C# Express and get hacking.
Amazing what one can do in 54 lines of code.
And we open a browser to http://localhost:8080/time/GetTime:
Isn't that *cough* *choke* pretty *gag*.
I suddenly had a flash of nostalgia...of longing...for Xaml.
Xaml: that wonderful language where document-object mapping is implicit, trivial, and human-understandable.
Thankfully, XamlWriter is publicly available and WCF is insanely, gratuitously, wonderfully extensible.
- WCF services have endpoints.
- Endpoints have contracts.
- Contracts have operations.
- Operations have behaviors.
- Behaviors have formatters.
- Formatters can have custom messages--for instance, XamlMessage.
The code is a bit longer, but it's mostly boiler plate:
And (drumroll) the output from http://localhost:8080/time/GetTime:
Isn't that pretty? The XmlnsDefinition assembly attribute is the icing that gives you the pretty xmlns.
Do other folks love Xaml? Do you wish it was available outside PresentationFramework.dll?
Let me know. I'm thinking of starting a campaign.
Hear that, Rob? :-)