0
我有調用WCF服務的MVC客戶端。 MVC客戶端需要在httprequest中傳遞一個自定義標頭。 MVC客戶端也使用Unity for DI。如何將http頭添加到WCF通道
我已經通過SO POST和其他鏈接,但他們都建議使用消息檢查器和自定義行爲(這可能是正確的方式),但我尋找快速和骯髒的方式,因爲這將是臨時解決方案。
// Unity type Registration
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterType<IDocumentManagementChannel>(new PerRequestLifetimeManager(),
new InjectionFactory(f=> CreateDocumentManagementChannel()));
}
private static IDocumentManagementChannel CreateDocumentManagementChannel()
{
var factory = new ChannelFactory<IDocumentManagementChannel>("BasicHttpEndPoint");
var channel = factory.CreateChannel();
// How do i add HttpHeaders into channel here?
return channel
}
在上面的代碼中如何在創建通道後添加自定義標頭?