4

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

Mitchell CSharp
  • 101
  • 1
  • 11
  • Option 1 (best): migrate away from WCF (the whole WS-* approach is old and now recognised as a dead end: RESTful APIs are the current practice). Option 2 (in the meantime): look at CoreWCF. – Richard Aug 11 '22 at 07:13
  • Does this answer your question? [Svcutil Configuration files are not supported.net core](https://stackoverflow.com/questions/71464797/svcutil-configuration-files-are-not-supported-net-core) – Tom W Aug 11 '22 at 07:27
  • Thank you Richard for your input! Could I just know is it technically possible or not to call Dot Net Framework 3.5 from any Dot Net Core application? – Mitchell CSharp Aug 11 '22 at 07:53
  • Hi Tom, I looked to your link, thank you! I dont really understand the part: wcf is not ported to .net core. Microsoft recommends using gRPC instead. – Mitchell CSharp Aug 11 '22 at 07:55
  • notice CoreWCF is the server and not the client, if you want to have a client library https://github.com/dotnet/wcf – Rand Random Aug 11 '22 at 09:51
  • are you sure you have wcf? because you talk about webservice, aswell - those arent the same thing: https://stackoverflow.com/questions/351334/web-service-vs-wcf-service – Rand Random Aug 11 '22 at 09:51
  • Thank you Rand Random for your comment, that is a good point. – Mitchell CSharp Aug 25 '22 at 05:29

3 Answers3

5

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

    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);
    }
    
Mitchell CSharp
  • 101
  • 1
  • 11
3

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!

Enki403
  • 31
  • 1
0

in addition to already provided useful answers/comments, this works just as well:

string remoteAddress = "http://localhost:44467/WebService1.asmx";
System.ServiceModel.Channels.Binding binding = new BasicHttpBinding();
System.ServiceModel.EndpointAddress endpointAddress = new EndpointAddress(remoteAddress);

using (var service1 = new ServiceReference1.WebService1SoapClient(binding, endpointAddress))
{
    var sr = await service1.AAsync().ConfigureAwait(false);
}

there was no need to run svcutil, vs2022 added reference.cs

yob
  • 528
  • 4
  • 9