.NET Core中的WCF参考 [英] WCF reference in .NET Core
问题描述
如何将WCF引用到.NET Core客户端?我下载并安装了 WCF Service Preview插件,但是当我尝试添加引用时出现错误
how can I reference WCF to my .NET Core client? I download and install "WCF Service Preview" plugin but when I trying add reference I got error
错误:没有与.Net Core兼容的端点找到了应用程序。
工具发生错误。
Error: No endpoints compatible with .Net Core apps were found. An error occurred in the tool.
无法生成服务引用。
当我尝试在浏览器中进行服务时,效果很好。有任何想法吗 ?
我的WCF的网络配置:
When I try service in my browser, works fine. Any ideas ? My WCF's web config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="ServiceLayer.TeamManagementService" behaviorConfiguration="GetDataBehavior">
<endpoint address="" binding="webHttpBinding" contract="ServiceLayer.ITeamManagementService" behaviorConfiguration="GetDataEndpointBehavior"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="GetDataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="GetDataEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<directoryBrowse enabled="true"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
推荐答案
几天前我遇到了类似的问题,无法找到扩展无法正确识别端点的特定原因。我通过创建一个包含实际WCF服务代理的类库项目解决了这一问题。然后,NET Core项目可以引用该项目,并在没有连接引用的情况下间接调用该服务。
I faced a similar problem a couple of days ago and could not find a specific reason to why the endpoint was not recognized correctly by the extension. I solved this by creating a class library project that includes a proxy for the actual WCF service. The NET Core project can then reference this project and indirectly call the service without connected references.
如果尚未找到解决问题的方法,请查看我的github存储库中查看示例:
https://github.com/ jolmari / netcore-wcf-service-proxy
If you haven't found a solution to the problem yet, have a look at my github repository to see an example: https://github.com/jolmari/netcore-wcf-service-proxy
这篇关于.NET Core中的WCF参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!