views:

67

answers:

2

I want to prepend the following text to the response body of a WCF operation:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="transform.xslt" type="text/xsl" ?>

Problem is that the Message class uses XML Readers and Writers to specify the contents of the message. Inserting this text as the first line after the tag makes the Message not well formatted.

So where does the Message object get read and the body contents written to the HTTP response stream? That is where I want to insert the two lines above.

+1  A: 

It's called Interception, and you can define your own custom interceptions. Take a look at the following links with explanations and samples: http://msdn.microsoft.com/en-us/library/ms751495.aspx http://blogs.msdn.com/drnick/archive/2007/03/07/message-flow-interception-points.aspx

Boris Modylevsky
The Interceptor still sends and receives Message objects. So I still have the same problem with the message not being well formatted.
Ries
I think I need a custom Transport channel element.
Ries
A: 

What I needed was a custom MessageEncoder.

Ries