In order to implement few validations I have written separate method which expects message instance as parameter. In side that method I process the input message . but once I try to run my service it throws above error and terminates the process . after spending some time with the issue I could identify the issue.
according to the MSDN The body of a
Message instance can only be consumed or written once. but I have tried several times to read message instance inside my validation logic.
“You can access the body of a Message only once, regardless of how it is accessed. A message object has a State property, which is initially set to Created. The three access methods described in the preceding list set the state to Written, Read, and Copied, respectively. Additionally, a Close method can set the state to Closed when the message body contents are no longer required. The message body can be accessed only in the Created state, and there is no way to go back to the Created state after the state has changed.”
There fore we need to use CreateMessageCopy method for reading the message.
Bingo its works