0

I am looking to integrate with a 3rd party using their SOAP API. I have tested SOAP calls via SoapUI successfully and I am now trying to do the same in my .NET core application.

I am looking to use basic authentication by passing an address header with the call.

I am currently doing the following:

string credential = "UserName" + ":" + "Password";
AddressHeader authAddressHeader = AddressHeader.CreateAddressHeader("Authorization", string.Empty, "Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(credential)));
AddressHeader[] addressHeaders = new AddressHeader[] { authAddressHeader };

EndpointAddress endpointAddress = new EndpointAddress(new Uri("https://dm-delta.metapack.com/dm/services/ConsignmentService"), addressHeaders); // passing in authentication  via address header

// instantiating 3rd party client service reference code generated via WCF and passing in endpoint with authentication
var client = new ConsignmentServiceClient(ConsignmentServiceClient.EndpointConfiguration.ConsignmentService, endpointAddress); 

When I attempt to call a client method I receive the following error message:

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. 
The authentication header received from the server was 'Basic realm="default"'.

I have compared the authorization header string when debugging my application and it is the exact same as the authorization in the headers from my SOAP request in SoapUI so unsure why it is complaining?

This is the first time I have attempted a SOAP API integration in .NET core, any help or suggestions on what I may be doing wrong is greatly appreciated.

Thanks in advance

Daniel
  • 1

1 Answers1

0

Maybe you can set the safe mode in config:

<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" algorithmSuite="default" />
</Security>

WCFTestClient The HTTP request is unauthorized with client authentication scheme 'Anonymous'
Calling a SOAP service in .net Core

Lan Huang
  • 613
  • 2
  • 5