hello,
I have a .net core 2.0 web api and I want to use it to call a SOAP service and do what I have to do but I can not do it until now. I have tried everything.How can I do that? Please help
Hi Shahzaibrocks,
Have you tried using the WCF Web Service Reference Provider Tool? Did you see any errors when using this tool?
Thanks,
Daniel
Take a look at this
https://github.com/lishilei0523/WCF-DotNetCore
Okay, so the thing is if you use Visual Studio and use WCF web services references tool on the dotnet core api project it will not work and it will give error. I know because I tried it. So as a work around I created a dotnet core library project and tried to use WCF Web Services Reference tool in it and tried to use the SOAP service in it and what I discovered was It works from the dotnet core library project but do not work in dotnet core api project. So I used this dotnet core library that is now working with SOAP and I added its reference in the dotnet api project and started using it in api and it works. Although it took me 2 days to think of this way around. For 2 days I was trying to use the SOAP api in the dotnet core api project so, it sucks when I was able to solve this problem so easily. I learned a lesson from this is that always try to look a problem from different angle and try different things and you will be able to solve the problem.
I'm glad you found a workaround. Can you share the details of the error you get when using the tool in a .NET Core Web API project so we can look into why it isn't working for you?
@Shahzaibrocks, let us know if you need any further help. thanks,
I also tried what @Shahzaibrocks, had suggested but I was not as lucky. I can create the proxy and work with the generated classes and everything compiles fine. However, when I try to reference the library (which contains the service) from another project I continue to get the exception in question. I am referencing all the latest System.ServiceModel.* packages. I have even added the same packages and a reference to the System.Web.Services in the project that calls the library which contains the service and still get this message. Any updates on this or suggestions?
@RolandoAvila It sounds like you're hitting a different problem from the one described in this issue. Can you please open a new issue with the details of your project setup and what the error message you're seeing says?
Guys, I have an .asmx web service hosted which I cannot change or have access. I am working on .net core 2.2 class library and want to consume this .asmx web service.
I tried adding the web reference using "WCF Web Service Reference Provider Tool", but it does not generates the Reference.cs correctly. The Service class is never generated in the Reference.cs.
I, also, tried wsdl.exe and was able to generate the proxy class. When I added this class to .net core 2.2 class library, it gave me System.Web.Services error as this dll in not available in .net core 2.2.
Has anyone tried to consume a .asmx web service in .net core 2.2? I am currently not able to find any solution to my problem. Seems like .net core 2.2 does not have a good tool to add .asmx service reference.
Will appreciate your help...
@Developer2aa,
Although not yet on .net core 2.2, I was able to resolve this using a previous version of it. I resolved this by the following instructions.
To rebuild your ASMX Service proxies use the following Developer Command prompt
Then run it as follows. You will need to specify the drive and location you want the auto generated file to be written to.
* Visual Studio 2017 Developer Command Prompt v15.7.5
* Copyright (c) 2017 Microsoft Corporation
C:\MyProjects\MySubFolder>svcutil http://theurlofthewebservice.com/SomeService.asmx /language:c# /t:code /out: ServiceName.cs
You should then see …
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.6.1055.0]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from ‘http://theurlofthewebservice.com/SomeService.asmx‘ using WS-Metadata Exchange or DISCO.
Generating files...
C:\MyProjects\MySubFolder\ServiceName.cs
C:\MyProjects\MySubFolderoutput.config
C:\MyProjects\MySubFolder>
Hope this helps.
Here's what worked for me in VS2019 v16.1.6 for a .NET Core class library referencing a SOAP WSDL:
If Connected Services does not exist in the project, right-click on the project name and select Add Connected Service.

Otherwise right-click on Connected Services and select Add Connected Service.

Select Microsoft WCF Wb Service Reference Provider

Then enter the WSDL link in the URI field and give the Service Reference a Namespace name.

A folder should be created with the service name, and in there two files should have been generated: a json file with config info, and a Reference.cs file with all the C# code that implements the WDSL in a class.
IMPORTANT NOTE: I had problems as described in https://github.com/dotnet/wcf/issues/2219#issuecomment-324100635 but the code provided by @shmao resolved that:
MethodInfo method = typeof(XmlSerializer).GetMethod("set_Mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
method.Invoke(null, new object[] { 1 });
For more info see Accessing Services Using a WCF Client and Use the WCF Web Service Reference Provider Tool.
Thanks @dasetser for the link to Use the WCF Web Service Reference Provider Tool mentioned above.
Most helpful comment
Okay, so the thing is if you use Visual Studio and use WCF web services references tool on the dotnet core api project it will not work and it will give error. I know because I tried it. So as a work around I created a dotnet core library project and tried to use WCF Web Services Reference tool in it and tried to use the SOAP service in it and what I discovered was It works from the dotnet core library project but do not work in dotnet core api project. So I used this dotnet core library that is now working with SOAP and I added its reference in the dotnet api project and started using it in api and it works. Although it took me 2 days to think of this way around. For 2 days I was trying to use the SOAP api in the dotnet core api project so, it sucks when I was able to solve this problem so easily. I learned a lesson from this is that always try to look a problem from different angle and try different things and you will be able to solve the problem.