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

Mit*_*arp 5 c# wcf soap .net-core .net-4.8

我有 Dot Net Framework 3.5 Web 服务: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://howtodomssqlcsharpexcelaccess.blogspot.com/2019/06/mvc-consume-web-service -service.html

Mit*_*arp 6

我的导师给了我一篇文章,提供了答案。Khalidabuhakmeh 先生出色地解释了如何在 .NET Core 中使用 SOAP API;谢谢你!

总结一下他们的步骤:

  1. 检查是否安装了.NET Core 2.1;如果没有,请从 Microsoft 下载并安装.

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

  3. 在终端输入:

    dotnet tool install dotnet-svcutil
    
    Run Code Online (Sandbox Code Playgroud)
  4. 在终端输入:

    dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso
    
    Run Code Online (Sandbox Code Playgroud)

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

  1. 在终端输入:--sync

    dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso --sync
    
    Run Code Online (Sandbox Code Playgroud)

    更多信息

    或者

    输入另一个 WSDL 链接:

    dotnet dotnet-svcutil <wsdl url>
    
    Run Code Online (Sandbox Code Playgroud)
  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);
    }
    
    Run Code Online (Sandbox Code Playgroud)