יום ראשון, 10 במרץ 2013

10-3-2013 wcf

 we need that the server should know which client has send the message to it.

 

Client Side

 
using (OperationContextScope scope = new OperationContextScope((IContextChannel)channel))
{
    MessageHeader<string> header = new MessageHeader<string>("secret message");
    var untyped = header.GetUntypedHeader("Identity", "http://www.my-website.com");
    OperationContext.Current.OutgoingMessageHeaders.Add(untyped);
 
    // now make the WCF call within this using block
}
 

server-side:

 
MessageHeaders headers = OperationContext.Current.IncomingMessageHeaders;
string identity = headers.GetHeader<string>("Identity", "http://www.my-website.com");

אין תגובות:

הוסף רשומת תגובה