I'm working on a Client that communicate with a legacy system utilizing SOAP WCF WS-Addressing messages.
Additionally, its required to customize the SOAP-Envelope header with To
and Action
headers that contains custom information.
I was able to set the To
and Action
SOAP-Envelope header with the information through utilizing the OperationContextScope
as shown in the code below:
public async Task<getAttorneyResponseStructure> GetAttorneyAsync(GetAttorneyRequestStructure getAttorneyRequestStructure)
{
try
{
using (new OperationContextScope(Client.InnerChannel))
{
getAttorneyRequestStructure.AttorneyHeader = Header;
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;
}
}
When I run the code and try to send the message I end up with the an exception Multiple headers with name 'Action' and namespace 'http://schemas.microsoft.com/ws/2005/05/addressing/none' found.
By looking at the exception stack as attached in the picture, it seems there is an object containing the same information of the header that I'm trying to add.
So, my question is there a work around changing the Namespace of the Action
header or modify the existing Action
that containing the set Namespace?