我有一个面向 .NET Core 的应用程序。
当我尝试导入 wsdl 文件时,出现以下错误。
Scaffolding Code ...
Error:Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://xml.amadeus.com/2010/06/Session_v3' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://xml.amadeus.com']/wsdl:portType[@name='AmadeusWebServicesPT']
Warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://xml.amadeus.com']/wsdl:portType[@name='AmadeusWebServicesPT']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://xml.amadeus.com']/wsdl:binding[@name='AmadeusWebServicesBinding']
Warning: Cannot import wsdl:port
Detail:
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://xml.amadeus.com']/wsdl:service[@name='AmadeusWebServices']/wsdl:port[@name='AmadeusWebServicesPort']
Error: No endpoints compatible with .Net Core apps were found.
An error occurred in the tool.
Failed to generate service reference.
是否有任何解决方案或解决方法来解决该问题?
谢谢。
编辑:
我已经想通了这个问题。要重新生成 stub ,我需要直接从命令行运行“svcutil.exe”(或在某些虚拟 C# 项目中生成 stub ),因为 WCF 连接服务无法从此 WSDL 生成 stub 。
有关 wsdl 的生成代码使用以下 .Net Standard 1.6 不支持的属性。
SerializableAttribute, DesignerCategoryAttribute
当我手动创建这两个属性时,我就可以构建我的应用程序。
最佳答案
我们可以从 addservices
以 2 种方式添加服务或来自 dotnet-svcutil
工具。
问题在于您的 Web 服务端点的 WSDL 使用不同的方式来存储 XML 操作数据。正如 Henk 所指出的,在手动运行 dotnet-svcutil
时使用包装标志工具是这里的解决方案。
按着这些次序:
<ItemGroup>
中添加以下节点节点:<DotNetCliToolReference Include="dotnet-svcutil" Version="1.0.*" />
dotnet restore
dotnet svcutil https://smp.difi.no/ws/2.0?wsdl -wr
关于wcf - 将 Wsdl 作为连接服务导入时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42361765/