asp net core soap request ws-addressing

682 Views Asked by At

I am creating a wcf client on core. I create a binding.

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

I need to add MessageID, ReplyTo fields to the request for ws-addressing. How to do it correctly?

I tried to overwrite request - it didn't work. All examples are mostly on the usual net framework It seems there is a library microsoft.web.services2, but I do not understand how to use it.

1

There are 1 best solutions below

0
On

I'm working on the same requirement, I've found the way to modify the header is work with the OperationContextScope and work with OperationContext.Current.OutgoingMessageHeaders and change the properties.

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;
  }
}