I'm attempting to test a [MessageContract]
class against an existing sample message, and I'm looking for a way to simplify development by reading the sample message file into an instance of my [MessageContract]
class and seeing how it worked out (I'm dealing with a particularly complex contract here, of non-WCF origin).
My [MessageContract]
class looks something like this:
[MessageContract(IsWrapped = true, WrapperName = "wrapper", WrapperNamespace = "somens")]
public class RequestMessage
{
[MessageHeader(Name = "HeaderElem", Namespace = "otherns")]
public XElement CorrelationTimeToLive { get; set; }
[MessageBodyMember(Name = "id", Namespace = "somens")]
public XElement id { get; set; }
}
I can read the file into an instance of the Message
class, using code such as the following:
var xr = XmlReader.Create("sample_message.xml");
var msg = Message.CreateMessage(xr, int.MaxValue, MessageVersion.Soap12);
That's not particulary helpful, however, because it doesn't allow me to test my [MessageContract]
class at all.
Somewhere in the guts of WCF is a system for turning this Message
instance into an instance of a particular [MessageContract]
class, but what is it?