【问题标题】:asp net core soap request ws-addressingasp net core soap请求ws-addressing
【发布时间】:2021-08-19 09:56:50
【问题描述】:

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

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

我需要在 ws-addressing 请求中添加 MessageID、ReplyTo 字段。 如何正确操作?

我试图覆盖请求 - 它不起作用。 所有示例大多在通常的网络框架上 好像有一个库 microsoft.web.services2,但我不明白如何使用它。

【问题讨论】:

  • 我不确定你想要做什么甚至是可能的。至少可以说,核心中的 WCF 支持是有限的,ws-addressing 基本上意味着“回调支持”,即 SOAP 服务器。 WCF-core 不支持 SOAP 服务器。而且永远不会:微软说他们认为 SOAP 是一种遗产。如果您需要带有回调的 SOAP,那么 net-core 不是您应该使用的技术。
  • 我解决了我的问题CustomBinding binding = new CustomBinding(); binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, System.Text.Encoding.UTF8)); binding.Elements.Add(new HttpsTransportBindingElement());

标签: asp.net-core .net-core soap wsdl ws-addressing


【解决方案1】:

我正在处理相同的要求,我发现修改标头的方法是使用 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;
  }
}

【讨论】:

  • 谢谢。有用的经验
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-14
  • 2010-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-27
  • 1970-01-01
相关资源
最近更新 更多