wcf - 将 Wsdl 作为连接服务导入时出错

标签 wcf visual-studio-2015 wsdl .net-core

我有一个面向 .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 时使用包装标志工具是这里的解决方案。

按着这些次序:

  • 编辑您的 .csproj 文件并在 <ItemGroup> 中添加以下节点节点:<DotNetCliToolReference Include="dotnet-svcutil" Version="1.0.*" />
  • 从 .csproj 文件所在的文件夹中打开 PowerShell 终端。
  • 运行 dotnet restore
  • 运行 dotnet svcutil https://smp.difi.no/ws/2.0?wsdl -wr
  • 关于wcf - 将 Wsdl 作为连接服务导入时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42361765/

    相关文章:

    javascript - 构建空白 Cordova 应用程序会出现多个错误

    visual-studio-2015 - 高效使用 Visual Studio diff 编辑器

    java - 从 WSDL 链接 java 访问 Web 服务

    c# - .NET 4 WCF REST 服务 404 一些请求

    .net - 如何在 iis 中托管启用了网络命名管道绑定(bind)的 wcf 应用程序?

    .net - 如何从 wcf 服务中检索未知类型?

    c++ - 使用 ATL 子类化在 Windows 10 64 位上随机崩溃

    c# - WCF over HTTPS 和签署正文

    wsdl - WSP0075:策略断言“TransportBinding”被评估为“未知”。为什么?