Mr Andersson

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!

Advertisements

Written by anderssonjohan

May 7, 2009 at 16:13

Posted in programming

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: