Unfortunately in WCF, it isn't quite as easy. However, you can do it once for all operations. You can implement IClientMessageInspector which allows you to modify every request before sending it. Then add your custom message header. Note that this is a Soap Message Header not an HTTP header.
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request,
System.ServiceModel.IClientChannel channel)
{
request.Headers.Add(MessageHeader.CreateHeader("CultureInfo",
"http://mynamespace", Thread.CurrentThread.CurrentUICulture.Name));
return null;
}
On the server side, implement IDispatchMessageInspector
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request,
IClientChannel channel, InstanceContext instanceContext)
{
string culture = request.Headers.GetHeader<string>("CultureInfo",
"http://mynamespace");
Thread.CurrentThread.CurrentCulture
= CultureInfo.CreateSpecificCulture(culture);
return null;
}
You'll also need to implement some custom behaviors to apply the message inspectors. For implementing the behaviors, see the MSDN pages:
http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.aspx http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector%28v=vs.110%29.aspx