VJAI
VJAI

Reputation: 32768

Read the soap message body contents in WCF custom message filter

I've been working with WCF routing and implemented a custom message filter,

    public override bool Match(Message message)
    {
        MessageBuffer buffer = message.CreateBufferedCopy(Int32.MaxValue);

        var msg = buffer.CreateMessage();

        XmlDictionaryReader reader = msg.GetReaderAtBodyContents();

        string paramsXml = reader.ReadOuterXml();

        ....
        ....

        return serviceType.Equals(service);
    }

I'm getting the following exception "This message cannot support the operation because it has been copied." eventhough I'm creating a buffered copy. Can anyone help me on this?

Upvotes: 1

Views: 1053

Answers (2)

kuhajeyan
kuhajeyan

Reputation: 11017

This is apparently the problem with VS debugger. does not happen with soap ui or other clients. hope this will be useful for somebody struggling with same issue.

Upvotes: 3

Richard Blewett
Richard Blewett

Reputation: 6109

You need to set routeOnHeadersOnly = false in the routing behavior

Then you implement the operations that take message buffers

Upvotes: 2

Related Questions