Jun 26, 2007

WCF Message Copying

A WCF Message can only be read once. The Message class contains a "State" property indicating if this was already done before. So quite often you need to copy a Message object:

// a Message can only be read once, so create a copy

MessageBuffer mb = orgMessage.CreateBufferedCopy(int.MaxValue);

System.ServiceModel.Channels.Message copyMessage = mb.CreateMessage();

There is an extensive article about the WCF Message type at MSDN.

No comments:

Post a Comment