【问题标题】:Authenticating SOAP call via HTTP headers通过 HTTP 标头验证 SOAP 调用
【发布时间】:2021-12-24 02:41:41
【问题描述】:

我希望使用他们的 SOAP API 与第三方集成。我已经通过 SoapUI 成功测试了 SOAP 调用,现在我正尝试在我的 .NET 核心应用程序中做同样的事情。

我希望通过在调用中传递地址标头来使用基本身份验证。

我目前正在做以下事情:

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

当我尝试调用客户端方法时,我收到以下错误消息:

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

我在调试我的应用程序时比较了授权标头字符串,它与我在 SoapUI 中的 SOAP 请求的标头中的授权完全相同,所以不确定它为什么会抱怨?

这是我第一次尝试在 .NET 核心中集成 SOAP API,非常感谢任何有关我可能做错的帮助或建议。

提前致谢

【问题讨论】:

    标签: .net wcf soap


    【解决方案1】:

    也许你可以在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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-11
      • 2018-06-13
      • 1970-01-01
      • 2014-09-27
      • 2016-03-25
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      相关资源
      最近更新 更多