Message.CreateBufferedCopy Method
Stores an entire Message into a memory buffer for future access.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Parameters
- maxBufferSize
- Type: System.Int32
The maximum size of the buffer to be created.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException |
maxBufferSize is smaller than zero. |
| ObjectDisposedException |
The message is closed. |
| InvalidOperationException |
The message has been copied, read or written. |
The body of a Message instance can only be accessed or written once. If you want to access a Message instance more than once, you should use the MessageBuffer class to completely store an entire Message instance into memory. A MessageBuffer instance is constructed by calling CreateBufferedCopy of a Message instance.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Issue with CreateBufferedCopy
I have a message body which contains XML in which one of the elements is a base64 encoded string. When I create the message by calling:
msgInput = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "urn:whatever", new XmlNodeReader(xmlDoc));
Everything works fine until I add an implementation of IEndpointBehavior that attempts to modify the header of the soap message and place it back in the callstack and the element appears to have its contents trimmed from the beginning and only including the end of the base64 encoded string.
I am doing:
MessageBuffer msgbuf = message.CreateBufferedCopy(int.MaxValue);
XPathNavigator nav = msgbuf.CreateNavigator();
and looking at the XML in the navigator before I even add my custom headers I can see that the body does not match what I used originally to create the message.
I am not sure what this method is doing but it does not work for me.
msgInput = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "urn:whatever", new XmlNodeReader(xmlDoc));
Everything works fine until I add an implementation of IEndpointBehavior that attempts to modify the header of the soap message and place it back in the callstack and the element appears to have its contents trimmed from the beginning and only including the end of the base64 encoded string.
I am doing:
MessageBuffer msgbuf = message.CreateBufferedCopy(int.MaxValue);
XPathNavigator nav = msgbuf.CreateNavigator();
and looking at the XML in the navigator before I even add my custom headers I can see that the body does not match what I used originally to create the message.
I am not sure what this method is doing but it does not work for me.
- 8/4/2011
- Miguel C
Note