在 .NET Core 中使用自定义绑定 Web 服务服务

Consuming custom binding web service service in .NET Core

我可以使用下面的自定义绑定配置在我的 .NET Framework 应用程序中成功使用工作日 Web 服务。

<customBinding>
    <binding name="Human_ResourcesBinding">
        <security enableUnsecuredResponse="true" authenticationMode="UserNameOverTransport" />
        <textMessageEncoding messageVersion="Soap11" />
        <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
</customBinding>

Human_ResourcesPortClient hr = new Human_ResourcesPortClient();

hr.Endpoint.Address = new EndpointAddress("https://wd5-impl- 
   services1.workday.com/ccx/service/<TENANT_NAME>/Human_Resources/v32.0");

hr.ClientCredentials.UserName.UserName = "Username@Tenant"; 
hr.ClientCredentials.UserName.Password = "Password";

当我像下面那样使用 basichttps 绑定时,我收到一条错误消息,提示用户名和密码不正确。

binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);

我想将应用程序转换为 .NET Core,但我不确定是否可以在任何地方指定自定义绑定配置,或者我是否需要以编程方式指定自定义绑定。如果我需要以编程方式执行此操作,任何人都可以指出正确的方向或示例以帮助我构建此类配置吗?

目前.NET Core不支持创建WCF服务,但您可以在.net Core中创建WCF客户端来调用WCF服务。虽然您可以在 .NET Core 中调用 WCF 服务,但它会受到一些限制。 .net core中的WCF客户端只支持四种绑定:BasicHttpBinding、CustomBinding、NetHttpBinding、NetTcpBinding,.NET Core中安全特性不多。我的建议是在 .NET Framework 中使用 WCF。

关于core对WCF的支持,可以参考这个link:

https://github.com/dotnet/wcf