How to get data from a WCF data contract object into the message headers

367 Views Asked by At

All of my data contract objects in my service inherit from BaseMessage...

[DataContract(Name = "BaseMessage", Namespace = "http://www..."]
public class BaseMessage
{
    [DataMember]
    public Guid MessageId { get; set; }
}

I am familiar with using Message Inspectors to look at the actual SOAP payload that goes across the wire. However, what I want to do is to somehow hook into the message pipeline to do the following:

  1. Look at an incoming message and read out of it the MessageId field ideally without searching the whole string message object for a string match - unless there is a fast way to do this.

  2. Extract out of a message the MessageId with a view to creating a header inside the message containing the MessageId. Again I dont really want to search the whole message for the a string match.

I am familiar with using IClientMessageInspector and IDispatchMessageInspector to look at the messages, but I think at this point in the pipeline I dont have access to the actual object to access its fields.

Thanks

1

There are 1 best solutions below

0
On

If you want to determine what members go in the body of the message versus its headers, you need a message contract.