Share via


How to modify Message object in Message Inspector class?

public void AfterReceiveReply(ref Message reply, object correlationState)
{
    //Create the buffer
    MessageBuffer buffer = reply.CreateBufferedCopy(13000);

    //Inspect the response (for now simply extract the body contents)
    Message thisReply = buffer.CreateMessage();
    XmlDictionaryReader reader = thisReply.GetReaderAtBodyContents();
    StringBuilder info = new StringBuilder();
    XmlWriter writer = XmlWriter.Create(info);
    writer.WriteNode(reader, true);
    writer.Close();
   
    reply = buffer.CreateMessage();

    //Close the buffer
    buffer.Close();
}

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=548528&SiteID=1