I have a following sample wcf service (using webHttpBinding): 

```
[ServiceContract]
public class Animals {

    [OperationContract]
    [WebGet(UriTemplate = "/{id}")]
    [ServiceKnownType(typeof(Dog))]
    public Animal GetAnimalById(string id) {
        switch (id) {
            case "1": return new Animal { Id = 1 };
            case "2": return new Dog { Id = 2 };
        }
        throw new ArgumentException();
    }
}

```

Types are defined as follows:

```
[DataContract]
[KnownType(typeof(Dog))]
public class Animal {
    [DataMember]
    public int Id { get; set; } 
}

public class Dog : Animal {
    [DataMember]
    public string Name { get; set; }
}

```

When 1 is supplied, the xml retured from the service is (xmlns omitted for brevity):

```
<Animal><Id>1</Id><Name i:nil="true"/></Animal>

```

When 2 is supplied: 

```
<Dog><Id>2</Id><Name i:nil="true"/></Dog>

```

And here is the question: **Why can't DataContractSerializer constructed for Animal deserialize second xml?** It throws something like: Expecting element 'Animal' from namespace 'bla bla'.. Encountered 'Element' with name 'Dog', namespace 'bla bla'.

Additional information:  

 1. If I construct DataContractSerializer supplying typeof(Dog) as parameter it obviously work.  

 2. If I construct DataContractSerializer supplying typeof(Animal) as parameter (cause I don't know the type of object I'm about to serialize / deserialize) and then serialize Dog the xml will look like this: 

```
<Animal i:type="Dog"><Id>0</Id><Name i:nil="true"/></Animal>

```

Which can in turn be deserialized using same serializer without any problem. Can I force WCF to serialize using DataContractSerializer supplied with base type rather than derived (which seems more reasonable and probably should be there by default anyway)?