简体   繁体   English

Http Bindings in.Net Core 使用带有 wcf 参考的库项目

[英]Http Bindings in .Net Core consuming a Library Project with wcf reference

My .net core 3.1 project references a class library project built in.Net Framework 3.5.我的 .net 核心 3.1 项目引用了内置于 .Net Framework 3.5 的 class 库项目。 The library project has a wcf service reference with bindings defined in app.config.库项目有一个 wcf 服务引用,绑定在 app.config 中定义。

In dotnet framework we usually provide the http bindings in the consuming project.在 dotnet 框架中,我们通常在消费项目中提供 http 绑定。

When I try to manually add service bindings in app.config in dotnet core (consuming project) I get this error - " Unrecognized configuration section system.serviceModel "当我尝试在 dotnet 核心(使用项目)的 app.config 中手动添加服务绑定时,我收到此错误 - “无法识别的配置部分 system.serviceModel

Is there any way in which I can provide http bindings in the project which references the library project.有什么方法可以在引用库项目的项目中提供 http 绑定。

Update 1更新 1

This is my app.config in dotnet core project -这是我在 dotnet 核心项目中的 app.config -

   <?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appSettings>
        <add key="username" value="usr"/>
        <add key="password" value="pass"/>
        <add key="logPath" value="c:\test\api_log.txt"/>    
    </appSettings>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="ListManagementSoap">
                    <security mode="Transport" />
                </binding>
                <binding name="ListManagementSoap1" />
                <binding name="ContactManagementSoap">
                    <security mode="Transport" />
                </binding>
                <binding name="ContactManagementSoap1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://ws.caigners.com/listmanagement.asmx"
                binding="basicHttpBinding" bindingConfiguration="ListManagementSoap"
                contract="ListManagementAPI.ListManagementSoap" name="ListManagementSoap" />
            <endpoint address="https://ws.caigners.com/contactmanagement.asmx"
                binding="basicHttpBinding" bindingConfiguration="ContactManagementSoap"
                contract="ContactManagementAPI.ContactManagementSoap" name="ContactManagementSoap" />
        </client>
    </system.serviceModel>
</configuration>

Currently, .net core does not support the creation of WCF services, but you can create WCF clients in .net core to call WCF services. Currently, .net core does not support the creation of WCF services, but you can create WCF clients in .net core to call WCF services. Although you can call WCF services in .net core, it is subject to some restrictions.虽然您可以在 .net 内核中调用 WCF 服务,但它受到一些限制。 The WCF client in .net core only supports four bindings: BasicHttpBinding, CustomBinding, NetHttpBinding, NetTcpBinding, and there are not many security features in .net Core. .net内核中的WCF客户端只支持四种绑定:BasicHttpBinding、CustomBinding、NetHttpBinding、NetTcpBinding,而Z2D50972FECCD376120896内核中的安全特性并不多。

在此处输入图像描述

If you want to recognize system.serviceModel, you need to install System.ServiceModel.Http.如果要识别system.serviceModel,需要安装System.ServiceModel.Http。 For more information about it, you can refer to this link .有关它的更多信息,您可以参考此链接

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

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