错误:PlatformNotSupportedException:不支持配置文件或 .NET Core 6 如何使用 SOAP .NET Framework wcf

2024-02-07

我有 Dot Net Framework 3.5 Web 服务:http://www.dneonline.com/calculator.asmx http://www.dneonline.com/calculator.asmx我想在 dot Net Core(3 或 6,任何版本)上使用它。

当我运行程序时,它抛出异常: PlatformNotSupportedException:不支持配置文件

从技术上讲是否可以从任何 Dot Net Core 应用程序调用 WCF Dot Net Framework 3.5?

参考:https://medium.com/compendium/integrating-with-soap-web-services-in-net-core-adebfad173fb https://medium.com/compendium/integrating-with-soap-web-services-in-net-core-adebfad173fb https://howtodomssqlcsharpexcelaccess.blogspot.com/2019/06/mvc-consume-web-service-service.html https://howtodomssqlcsharpexcelaccess.blogspot.com/2019/06/mvc-consume-web-service-service.html


我的导师给了我一篇文章 https://khalidabuhakmeh.com/consuming-soap-apis-in-dotnet-core这提供了答案。 Khalidabuhakmeh 先生出色地解释了如何在 .NET Core 中使用 SOAP API;谢谢你!

总结一下他们的步骤:

  1. 检查是否安装了.NET Core 2.1;如果不,从微软下载并安装 https://dotnet.microsoft.com/en-us/download/dotnet/2.1.

  2. 打开 Visual Studio 2019 或 Visual Studio 2022。

    • 创建 .NET Core 控制台应用程序。
    • 转到“查看”,然后单击“终端”。
    • 在终端输入:
      dotnet new tool-manifest
      
  3. 在终端输入:

    dotnet tool install dotnet-svcutil
    
  4. 在终端输入:

    dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso
    

如果您有同步操作并且确实有同步操作,那么:

  1. 在终端输入:--sync

    dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso --sync
    

    更多信息 https://github.com/dotnet/wcf/blob/main/release-notes/dotnet-svcutil-notes.md

    or

    输入另一个 WSDL 链接:

    dotnet dotnet-svcutil <wsdl url>
    
  2. 消耗肥皂:

     static async Task Main(string[] args)
     {
     var client = new TextCasingSoapTypeClient(
         TextCasingSoapTypeClient.EndpointConfiguration.TextCasingSoap,
         "https://www.dataaccess.com/webservicesserver/TextCasing.wso");
    
     var result =
         await client.AllLowercaseWithTokenAsync("THIS IS A STRING", "");
    
     // result: this is a string
     var value = result.Body.AllLowercaseWithTokenResult;
    
     Console.WriteLine(value);
    }
    
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误:PlatformNotSupportedException:不支持配置文件或 .NET Core 6 如何使用 SOAP .NET Framework wcf 的相关文章

随机推荐