.NETCore WCF basicHttpBinding

时间:2018-06-17 17:34:29

标签: .net wcf .net-core basichttpbinding

我正在重写.NET Core中调用外部Web服务的控制台应用程序。

我目前收到以下错误:

One or more errors occurred. (The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM, Negotiate'.)

通过更新App.config,我能够在旧版本的应用程序中解决此问题:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="EmployeeSoap" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="Ntlm" />
            <message clientCredentialType="Certificate" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="EmployeeSoap1" />
      </basicHttpBinding>
      <customBinding>
        <binding name="EmployeeSoap12">
          <textMessageEncoding messageVersion="Soap12" />
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="https://..." binding="basicHttpBinding" bindingConfiguration="EmployeeSoap" contract="TEST.EmployeeSoap" name="EmployeeSoap" />
    </client>
  </system.serviceModel>

我似乎无法找到任何好的资源来展示我如何在.NET Core中实现这一目标。我希望有人能指出我正确的方向。

提前致谢。

2 个答案:

答案 0 :(得分:4)

.NET Core 5 中让 System.ServiceModel.BasicHttpBinding 正确解析时,我遇到了相关问题。我必须安装 Nuget 包 System.ServiceModel.Http

在尝试使用 Microsoft WCF Web 服务引用提供程序添加新的连接服务后,这解决了 连接服务的问题。设置端点并生成连接引用后,References.cs 无法构建。添加这个包解决了这个问题。

答案 1 :(得分:0)

.NET Core中的NTLM身份验证也涵盖了in this question

您可能还对this discussion感兴趣。