首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >asp net核心soap请求ws-addressing

asp net核心soap请求ws-addressing
EN

Stack Overflow用户
提问于 2021-06-01 15:52:43
回答 1查看 98关注 0票数 1

我正在核心上创建一个wcf客户端。我创建了一个绑定。

var binding = new System.ServiceModel.BasicHttpsBinding();

我需要将MessageID、ReplyTo字段添加到ws-addressing请求中。怎样做才是正确的呢?

我试图覆盖请求--它不起作用。所有的例子大多都是在通常的.NET框架上似乎有一个库microsoft.web.services2,但我不明白如何使用它。

EN

回答 1

Stack Overflow用户

发布于 2021-11-18 08:31:31

我正在处理相同的需求,我已经找到了修改头部的方法是使用OperationContextScope,使用OperationContext.Current.OutgoingMessageHeaders并更改属性。

代码语言:javascript
复制
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;
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67784824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档