Home > Back-end >  error: PlatformNotSupportedException: Configuration files are not supported or How .NET Core 6 consu
error: PlatformNotSupportedException: Configuration files are not supported or How .NET Core 6 consu

Time:08-26

I have Dot Net Framework 3.5 Web Service: http://www.dneonline.com/calculator.asmx I want to consume it on dot Net Core (3 or 6, any version).

When I run the program, it throws exception: PlatformNotSupportedException: Configuration files are not supported

Is it technically possible or not to call WCF Dot Net Framework 3.5 from any Dot Net Core application?

Reference: 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

CodePudding user response:

My mentor gave me an article that provided the answer. Mister Khalidabuhakmeh does a great job explaining how to consume SOAP APIs in .NET Core; thank you!

To summarize their steps:

  1. Check if you installed .NET Core 2.1; if not, download from Microsoft and install.

  2. Open Visual Studio 2019 or Visual Studio 2022.

    • Create a .NET Core Console App.
    • Go to View, then click Terminal.
    • At the terminal, input:
      dotnet new tool-manifest
      
  3. At the Terminal, input:

    dotnet tool install dotnet-svcutil
    
  4. At the Terminal, input:

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

If you have synchronous operations and you do have synchronous operations, then:

  1. At Terminal input:

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

    More information

    or

    Input the other WSDL link:

    dotnet dotnet-svcutil <wsdl url>
    
  2. Consume SOAP:

     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);
    }
    

CodePudding user response:

I got the same error with http://www.dneonline.com/calculator.asmx. How I solve it was by adding to the constructor

CalculatorSoapClient.EndpointConfiguration.CalculatorSoap

or

CalculatorSoapClient.EndpointConfiguration.CalculatorSoap12

i.e.

public static int add(int x, int y){
    CalculatorSoapClient client = new CalculatorSoapClient(CalculatorSoapClient.EndpointConfiguration.CalculatorSoap);
    return client.Add(x, y);
}

I should add that I didn't edit Reference.cs as suggested in here!

  • Related