I keep getting an error when I have an interface with more than one method tagged with the XMLSerializerFormatAttribute and I'm not sure why...
[ServiceContract(Namespace = "http://www.mysite.com/Services/Foo", ConfigurationName = "IFoo")]
public interface IFoo
{
[OperationContract(Action = "http://www.mysite.com/Services/Foo/SelectBarOne", ReplyAction = "*")]
[XmlSerializerFormat(SupportFaults = true)]
BarOneResponse SelectBarOne(BarOneRequest request);
[OperationContract(Action = "http://www.mysite.com/Services/Foo/SelectBarTwo", ReplyAction = "*")]
[XmlSerializerFormat(SupportFaults = true)]
BarTwoResponse SelectBarTwo(BarTwoRequest request);
}
[MessageContract(IsWrapped = false)]
public sealed class BarOneRequest
{
public BarOneRequest() { }
}
[MessageContract(IsWrapped = false)]
[ServiceKnownType(typeof(BarOne))]
public sealed class BarOneResponse
{
public BarOneResponse()
{
Init();
}
public BarOneResponse(BarOne[] entities = null)
{
Init(entities);
}
private void Init(BarOne[] entities = null)
{
Entities = entities;
}
[MessageBodyMember(Namespace = "", Order = 0)]
public BarOne[] Entities { get; private set; }
}
[MessageContract(IsWrapped = false)]
[ServiceKnownType(typeof(BarTwo))]
public sealed class BarTwoRequest
{
public BarTwoRequest() { }
}
[MessageContract(IsWrapped = false)]
[ServiceKnownType(typeof(BarTwo))]
public sealed class BarTwoResponse
{
public BarTwoResponse()
{
Init();
}
public BarTwoResponse(BarTwo[] entities = null)
{
Init(entities);
}
private void Init(BarTwo[] entities = null)
{
Entities = entities;
}
[MessageBodyMember(Namespace = "", Order = 0)]
public BarTwo[] Entities { get; private set; }
}
My MS Service Tracer gives me the following error: System.InvalidCastException: Unable to cast object of type 'BarTwo[]' to type 'BarOne[]'. I really think it has to do with one of my attribute tags not being proper, but I can't figure out the correct combination.