简体   繁体   English

.NETCore WCF 基本HttpBinding

[英].NETCore WCF basicHttpBinding

I'm in the process of rewriting a console application in .NET Core that calls an external web service.我正在 .NET Core 中重写一个调用外部 Web 服务的控制台应用程序。

I'm currently getting the following error:我目前收到以下错误:

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'.) (HTTP 请求未经授权,客户端身份验证方案为“匿名”。从服务器收到的身份验证标头为“NTLM,协商”。)

I was able to resolve this in the old version of the application by updating the App.config as follows:我能够通过更新 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>

I can't seem to find any good resources to show my how to accomplish this in .NET Core.我似乎找不到任何好的资源来展示我如何在 .NET Core 中实现这一点。 I was hoping someone could point me in the right direction.我希望有人能指出我正确的方向。

Thanks in advance.提前致谢。

I had a related issue with getting System.ServiceModel.BasicHttpBinding to resolve correctly in .NET Core 5 .我有一个相关的问题,让System.ServiceModel.BasicHttpBinding.NET Core 5 中正确解析。 I had to install the Nuget package System.ServiceModel.Http .我必须安装Nuget 包System.ServiceModel.Http

This corrected a problem with the Connected Services , after attempting to add a new Connected Service with Microsoft WCF Web Service Reference Provider .在尝试使用Microsoft WCF Web 服务引用提供程序添加新的连接服务后,这解决了连接服务的问题。 After setting the endpoint and generating the connection reference, the References.cs could not build.设置端点并生成连接引用后, References.cs无法构建。 Adding this package fixed the problem.添加这个包解决了这个问题。

NTLM authentication in .NET Core was also covered in this question . .NET Core 中的 NTLM 身份验证也包含在这个问题中

You may also be interested in this discussion .您可能也对这个讨论感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM