嗯,你张贴的问题here和Can Bilgin作出了回答。 我在这里发布给那些比你有问题的人。
I think it should be possible to add the header manually... I would give it a go with the operationscope... from an earlier example:
Task<GetADGroupMemberResponse> AccountManagement.GetADGroupMemberAsync(GetADGroupMemberRequest request)
{
// CB: Creating the OperationContext
using (var scope = new OperationContextScope(this.InnerChannel))
{
// CB: Creating and Adding the request header
var header = MessageHeader.CreateHeader("Server", "http://schemas.microsoft.com/2008/1/ActiveDirectory/CustomActions", request.Server);
OperationContext.Current.OutgoingMessageHeaders.Add(header);
return base.Channel.GetADGroupMemberAsync(request);
}
}
cause on the http requests with the httpclient you can do something like (again from an earlier example):
var httpClient = new HttpClient();
var httpContent = new HttpRequestMessage(HttpMethod.Post, "http://app.proceso.com.mx/win8/login");
// NOTE: Your server was returning 417 Expectation failed,
// this is set so the request client doesn't expect 100 and continue.
httpContent.Headers.ExpectContinue = false;
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("user", "******"));
values.Add(new KeyValuePair<string, string>("pass", "******"));
httpContent.Content = new FormUrlEncodedContent(values);
HttpResponseMessage response = await httpClient.SendAsync(httpContent);
// here is the hash as string
var result = await response.Content.ReadAsStringAsync();
在我的Web服务调用被代理阻止之前,我看到过这个错误 – lockstock