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:
Check if you installed .NET Core 2.1; if not, download from Microsoft and install.
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
At the Terminal, input:
dotnet tool install dotnet-svcutil
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:
At Terminal input:
dotnet dotnet-svcutil https://www.dataaccess.com/webservicesserver/TextCasing.wso --sync
or
Input the other WSDL link:
dotnet dotnet-svcutil <wsdl url>
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!