0

I've created an ASP.Net core 3.1 project with Visual Studio 2019. I want to add a WSDL service as a web reference. But I can't. Why the Advanced button removed in this form.

Visual Studio 2019:

enter image description here

Old version:

enter image description here

I've read somewhere that, Web reference is deprecated. How can I do it?

UPDATE1: The errors of documentation example code when I added it as a service reference

enter image description here

Stefan
  • 17,448
  • 11
  • 60
  • 79
Saeid Amini
  • 1,313
  • 5
  • 16
  • 26

1 Answers1

0

You just should use the new method. The old one is deprecated - see the question in your comment: Web Reference vs. Service Reference.

The last answers sums it like it is. In the end, the reference is just the creation of a client library to call the service. That's it.

Adding a service reference allows you to create a WCF client, which can be used to talk to a regular web service provided you use the appropriate binding. Adding a web reference will allow you to create only a web service (i.e., SOAP) reference.

If you are absolutely certain you are not ready for WCF (really don't know why) then you should create a regular web service reference.

(see: https://stackoverflow.com/a/2158137/2416958)


So, to "fix" your issue:

You need to include the namespace which you used to create the client on top of your file:

In my example:

using ServiceReference1;

But it can be different in your case. You can find it at the generated files, its called ServiceReference1 in my case:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace ServiceReference1
{
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.1")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="webservice.magfa.com", ConfigurationName="ServiceReference1.MagfaSoapServer")]
    public interface MagfaSoapServer
    {

You need to create a new one with this:

var client = new MagfaSoapServerClient();
client.ClientCredentials = ...
Stefan
  • 17,448
  • 11
  • 60
  • 79