This is very odd. I have a data contract Y, which inherits from X.
I have a Converter class that returns Y when you call it.
I have a WebGet that is returning an HttpResponseMessage<X>.
I do the following: return new HttpResponseMessage<X>(ConvertToY(SOMETHINGHERE));
When I do this, the operation gets called infinitely until A) the server crashes or B) the client gives up and just simply returns "12031/Unknown":
Example Code:
[XmlRoot(ElementName = "X")]
[DataContract(Name = "X", Namespace="urn:a.b.c")]
public class X{
[DataMember]
public string SomeValue { get; set; }
}
[XmlRoot(ElementName = "X")]
[DataContract(Name = "X"), Namespace="urn:a.b.c")]
public class Y : X{
[DataMember]
public string SomeOtherValue { get; set; }
[DataMember]
public int Id { get; set; }
}
[WebGet(UriTemplate = "{id}"]
public HttpResponseMessage<X> GetSomeValue(int id){
return new HttpResponseMessage<X>(Converter.GetY(id));
}
public static class Converter{
public static Y GetY(int id){
return new Y{
Id = id,
SomeValue = "Some Value",
SomeOtherValue = "Some Other Value"
}
}
}
When I replace my return with return new HttpResponseMessage<X>(new X(){ Id = id, SomeValue = "SomeValue" });, it works. When I use this converter class it fails. Can someone please tell me why this is the case? This is definately a bug and i could really use this fix asap.