« Seeking .NET Compact Framework support in Visual Studio 2010? | Main | Enabling PING (aka ICMP) on Windows Azure roles »



Feed You can follow this conversation by subscribing to the comment feed for this post.


I was actually just looking at this code path last night. I figured out how to add a JSON media type to the processors but I was having trouble with adding it as the default processor. Unless you pass the accept header, it still defaults to XML. Have you had that issue?

Christian Weyer


you need to clean up first, like this:

public override void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList processors, MediaTypeProcessorMode mode)

processors.Add(new JsonNetProcessor(operation, mode));
processors.Add(new BsonProcessor(operation, mode));

Glenn Block

Nice post Christian!

In the current bits, we take the first processor in the response pipeline as the default. You can use clear that processor collection in the RegisterResponseProcessorsForOperation method by calling the ClearMediaTypeProcessors on the processors param. Then just add back in Json first and it should work.


It's a Very helpful article for me. Actually, I am fond of reading online punjabi news. Thanks for writing such a complete ..And,I wantn't to miss them.
Thank you for sharing..

Merlyn Morgan-Graham

I'm looking for a way to use Json.NET BSON that doesn't involve coding up a service framework, and doesn't encode the binary data as base64 (which is the best I've done so far). Something that streamed the data would be even better. This post looks perfect, but I also want to use this in production :)

You mentioned: "A more practical approach is to use Message or Stream as the response/request type and apply the serialization/deserialization inside the service façade operation implementation." Can you point me to some references, or basic classes I'd need to mess with to start along this path?

Ryan Riley

Excellent post! Would you mind if I added this into http://wcfhttpcontrib.codeplex.com/?


Christian Weyer

Hi Ryan,

sure, go ahead! Just include the original reference, pls.


Ryan Riley

Thanks! I just pushed it. Let me know if you would like me to add a copyright, etc. http://wcfhttpcontrib.codeplex.com/SourceControl/changeset/changes/768111a9a285

Ryan Riley

Btw, I noticed that WriteToStream didn't work. I worked with Glenn on it tonight and discovered that 1) the writer is closing the underlying stream before its use is completed (http://ydie22.blogspot.com/2008/02/about-idisposable-close-streams-and.html) and 2) the contents weren't flushed. Not sure if those are new issues with the latest bits, but I'm fixing them now. Should be up tomorrow.


will this approach honor [DataContract] / [DataMember] directives?


I am running my services through a windows service....where do I configure the custom host configuration?


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)

IMPORTANT: This is archived - and quite likely outdated - content, only kept online for reference purposes

Please visit thinktecture.com for up-to-date technical content.