【发布时间】:2011-08-26 03:43:16
【问题描述】:
我意识到这是一个被反复询问的问题,但我找不到可以查看的“陷阱”列表。
我正在编写一个 WCF 客户端,它将使用 SAP Web 服务,在我的 web.config 中使用 customBinding 并将 allowCookies 设置为 false 并启用对可靠会话的支持。我将我的 HTTP 标头设置如下:
var authCookie = new System.Net.Cookie();
var wcfClient = new SomeWcfClient();
using (var context = new OperationContextScope(wcfClient.InnerChannel))
{
var cookies = new CookieContainer();
cookies.Add(authCookie);
var endPoint = new EndpointAddress("http://someDomain.test/");
var httpRequest = new System.ServiceModel.Channels.HttpRequestMessageProperty();
OperationContext.Current.OutgoingMessageProperties.Add(System.ServiceModel.Channels.HttpRequestMessageProperty.Name, httpRequest);
httpRequest.Headers.Add(HttpRequestHeader.Cookie, cookies.GetCookieHeader(endPoint.Uri));
wcfClient.PerformOperation();
}
当我使用 Fiddler 时,我的 HTTP 标头没有出现。我也尝试过创建虚拟的 Referer 和 User-Agent 标头,认为我的 cookie 标头可能发生了一些特定的事情,但即使是其他标头也没有遇到。有什么想法吗?接下来我应该看哪里?
【问题讨论】: