Replace ClientCredentials with token Bearer header in OperationContextScope SOAP request

  • Thread starter Thread starter sveed
  • Start date Start date
S

sveed

Guest
Hi, I am requesting a SOAP service with WCF and .NET Core. For authorization I have used ClientCredentials but know the service changed authorization to token Bearer and I get "System.ServiceModel.FaultException: 'Validation error'" when trying to use

using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();

httpRequestProperty.Headers.Add("Authorization", "Bearer " + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx");

OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

........

}

I have also tried

MessageHeader tokenHeader = MessageHeader.CreateHeader("Bearer", "https://api.lantmateriet.se/distribution/produkter/taxering/v1.7", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx");
OperationContext.Current.OutgoingMessageHeaders.Add(tokenHeader);

but with no luck so please help!

Continue reading...
 
Back
Top