One issue I've run into a couple times while working on restive WCF messages is the need to have complete control over the output. For example, when I wanted to generate a custom proxy for my rest service, I wanted to take over the /jsdebug UriTemplate and output plain JS (not JSON).
When I initially wrote that proxy generator, I used some reflection to hack the XML Writer into doing what I needed. Then, digging around the JSON Error Handlers, I noticed the framework had an internal class to output raw text. What it boils down to is:
Byte[] buffer = Encoding.UTF8.GetBytes(messageBody);
writer.WriteStartElement("Binary", string.Empty);
writer.WriteValue(buffer);
writer.WriteEndElement();
Unfortunately, they take a very difficult route of doing that. To ease things, I've created this RawMessage class which wraps up a string and spits it out in raw format:
Hopefully that'll save someone a few minutes in the future.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5