Mr Andersson

Posts Tagged ‘xsl

How to inject XSL stylesheet reference in WCF service response using a Message encoder

leave a comment »

In order to shape up the presentation of the responses from a RESTful WCF web service to clients such as Firefox, you’ll need to add an XSL stylesheet reference.
In order to do this, the most straight forward thing to do is to hack into your XML serializable classes and implement this using IXmlSerializable.
Since we want to control this in our service, based on the endpoint URI, this approach was not suitable for our needs.
Also, we don’t like cluttering down our serializable entity classes with “presentation logic”/encoding stuff. 🙂

I posted a question about this in MSDN Forums and got a pretty nice answer from Marco Zhou. He has written a message encoder which injects the XSL stylesheet reference on a lower level which is exactly what we wanted to do.

Thanks Marco!

Written by anderssonjohan

May 7, 2009 at 16:13

Posted in programming

Tagged with , ,