简体   繁体   English

无法从 WCF 在 .net 核心 3 上生成 SOAP 客户端

[英]Cannot generate SOAP client on .net core 3 from WCF

I have a web service written on WCF.我有一个 web 服务写在 WCF 上。 I am trying to generate the client by using "Microsoft WCF Web Service Reference Provider".我正在尝试使用“Microsoft WCF Web Service Reference Provider”生成客户端。 My project is .net core 3 web api.我的项目是 .net 核心 3 web api。 But I get this error Warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. But I get this error Warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System. Web,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a'。 XPath to Error Source: //wsdl:definitions[@targetNamespace=' http://tempuri.org/ ']/wsdl:portType[@name='ILiveViewService'] XPath 到错误源://wsdl:definitions[@targetNamespace=' http://tempuri.org/ ']/wsdl:portType[@name='ILiveViewService']

Why is it trying to reference System.Web?为什么要引用 System.Web? It is a framework library.它是一个框架库。 It is not part of the CORE它不是核心的一部分

I had the same problem, trying to include a new WCF, but it didn't work, with the same error above.我有同样的问题,试图包含一个新的 WCF,但它没有工作,上面有同样的错误。

The conflict was between the references System.Web and Microsoft.AspNetCore.Mvc , probably when adding.冲突发生在引用System.WebMicrosoft.AspNetCore.Mvc之间,可能是在添加时。 It was giving conflict between both.它在两者之间产生冲突。

The solution was to remove any references from System.Web that I had on my controller.解决方案是从我的 controller 上的System.Web中删除所有引用。

Controller with error: Controller 出现错误:

[ApiController]
public class TesteController: ControllerBase {}

Controller without error: Controller 无错误:

public class TesteController: Controller {}

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

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