After reading this post: "http://wcf.codeplex.com/wikipage?title=jQueryHtmlForm" I went ahead and implemented the concept in my application.
I need to post forms to be stored in a document database. These forms have a constant set of fields (ie: Author, Date & Time, etc) and a payload which is always variable given the form type.
I found the JQuery Support the right tool for what I needed, so this is how my resource looks like:
[WebInvoke(Method = "POST", UriTemplate = "")]
public HttpResponseMessage Submit(JsonObject form)
var document = ExtractDocument(form);
//persist the document.. etc..
return new HttpResponseMessage(HttpStatusCode.Accepted, string.Empty);
catch (Exception ex)
The example above is just for illustration purpose, I removed irrelevant lines.
In order to post the form I used both alternatives, the one described in the example and just a plain form post to the /form endpoint... In both cases I got this exception:
Server Error in '/' Application.
To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. System.Json.JsonValue does not implement Add(System.Object).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. System.Json.JsonValue does not
Since I found no one else reporting this issue, I guess it has to be something I'm missing or doing wrong.
Thanks in advance,