I am writing an ASP.NET MVC 2 site with REST endpoints. I want to consume this service with ActiveResource in a Rails web application.
So far, I've managed to get routes setup in ASP.NET MVC that match the ActiveResource conventions. But where I'm having problems is with de-serializing the data that ActiveResource sends to the REST service.
It seems that Rails does xml serialization very different than .NET (but I haven't been able to find these conventions documented anywhere). For example, with a .NET class like this:
public class Person
{
public string first_name { get; set; }
public string last_name { get; set; }
public bool active { get; set; }
}
Here are some of the differences:
- .NET serializes the root as <Person> while rails does <person>
- .NET adds a namespace while rails does not
- .NET serializes the properties like <first_name> while rails does <first-name>
- .NET serializes the bool as <active> while rails does <active type="boolean">
Number 4 doesn't seem to cause any problems, but the other 3 cause .NET to not de-serialize the message. You can solve these problems by decorating the object with XmlRoot and XmlElement attributes. But this is error prone and tedious.
Does anyone know a better way to de-serialize XML in .NET which has been serialized by Rails' ActiveResource?