我正在核心上创建一个wcf客户端。我创建了一个绑定。
var binding = new System.ServiceModel.BasicHttpsBinding();
我需要将MessageID、ReplyTo字段添加到ws-addressing请求中。怎样做才是正确的呢?
我试图覆盖请求--它不起作用。所有的例子大多都是在通常的.NET框架上似乎有一个库microsoft.web.services2,但我不明白如何使用它。
发布于 2021-11-18 08:31:31
我正在处理相同的需求,我已经找到了修改头部的方法是使用OperationContextScope,使用OperationContext.Current.OutgoingMessageHeaders并更改属性。
public async Task<getAttorneyResponseStructure> GetAttorneyAsync(GetAttorneyRequestStructure getAttorneyRequestStructure)
{
try
{
using (new OperationContextScope(Client.InnerChannel))
{
//Client Custom Header
getAttorneyRequestStructure.AttorneyHeader = Header;
//Change the properties to ReplyTo/MessageId
OperationContext.Current.OutgoingMessageHeaders.To = new Uri("http://rydwvgsn01.spga.gov.sa/GSBExpress/Legal/MOJAttorneyInquiry/2.0/AttorneyInquiryService.svc");
OperationContext.Current.OutgoingMessageHeaders.Action = "http://tempuri.org/IAttorneyInquiryService/GetAttorney";
return await Client.GetAttorneyAsync(getAttorneyRequestStructure);
}
}
catch (Exception e)
{
throw;
}
}https://stackoverflow.com/questions/67784824
复制相似问题