WCF SoapHeaders

How to use soapheaders on WCF

Server:

public string Call1()
{
string a = OperationContext.Current.IncomingMessageHeaders.GetHeader<string>(“A”, “http://tempuri.org/);
int b = OperationContext.Current.IncomingMessageHeaders.GetHeader<int>(“B”, “http://tempuri.org/“);
}

Client:

public string CallWcf()
{
using (new OperationContextScope(_wcf.InnerChannel))
{
MessageHeader a= new MessageHeader<string>(Header.UserId).GetUntypedHeader(“A”, “http://tempuri.org/“);
OperationContext.Current.OutgoingMessageHeaders.Add(a); 
MessageHeader b= new MessageHeader<int>(Header.ProcessId).GetUntypedHeader(“B”, “http://tempuri.org/);
OperationContext.Current.OutgoingMessageHeaders.Add(b);
}
_wcf.Call1();
}     

 

_wcf = new POCWCFClient();
Advertisements

%d bloggers like this: