Q:

WebAPI Remove z:anyType Element from XML Results

I have an interface as follows
public interface IResponse
{
    IResponse GetSuccessResponse();
    IResponse GetErrorResponse();
}

I then have various classes that implement logic as follows
[KnownType(typeof(DefaultResponse))]
[DataContract(Namespace = "")]
public class DefaultResponse : IResponse
{
    [DataMember(Order = 0)]
    public string Status { get; set; }

    [DataMember(Order = 1)]
    public string Info { get; set; }

    public IResponse GetSuccessResponse()
    {
        return new DefaultResponse()
        {
            Status = "Accept",
            Info = "Success"
        };
    }

    public IResponse GetErrorResponse()
    {
        return new DefaultResponse()
        {
            Status = "Reject",
            Info = "Fail"
        };
    }
}

When returning a response in my WebAPI, I am using a factory pattern to get the IResponse type needed, and calling IResponse.GetErrorResponse. The problem is this always generates XML like the following
<z:anyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="" i:type="DefaultResponse" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
    <Status>Reject</Status>
    <Info>Fail</Info>
</z:anyType>

Is there any way to get rid of the z:anyType element and replace it with the actual class name. It works if I use the class directly, but not with the interface involved.
I am creating the response using the following type of code:
return request.CreateResponse(HttpStatusCode.InternalServerError, responseType.GetErrorResponse());

A:

I ended up changing this up a bit to instead use a custom serializer like the following answer
Web API - Dynamic to XML serialization
This provided me with the greatest flexibility as it allows you to output exactly what the class looks like in XML without any of the attributes on the class

