是否可以动态地将标头信息(或查询字符串)添加到 wcf 请求中?我一直在搞乱这样的 IWcfPolicy:
var xmlObjectSerializer = new DataContractSerializer(typeof(string));
var addressHeader = AddressHeader.CreateAddressHeader("client", "http://tempuri.org/", "someValue", xmlObjectSerializer);
var endpointAddress = new EndpointAddress(new Uri(url), new AddressHeader[] { addressHeader });
invocation.ChannelHolder.ChannelFactory.Endpoint.Address = endpointAddress;
invocation.Proceed();
但是,这不起作用。任何帮助都会非常感激。