How to Create SOAP Web Service Using WSDL in ASP.NET Core (.NET 8)

Introduction

In this tutorial we will show you how to make a SOAP service using WSDL in Visual Studio. We will be using .NET. We will be working with .NET 8. We want to teach you how to implement a SOAP service using WSDL in Visual Studio .NET Core, and .NET 8 is what we will be focusing on.

SOAP is a protocol that helps exchange information in web services. WSDL is a standard that describes the web service interface.

Even though REST is popular, many big banking systems still use SOAP. In fact, over 70% of enterprise-level banking systems rely on SOAP for reliable web services. This shows how important SOAP is in areas like finance and healthcare. Companies, like Salesforce, use SOAP APIs a lot.

NetSuite, a leading cloud ERP from Oracle, still offers SOAP APIs, which are capable of performing batch transactions via API, whereas such a feature is not available with its REST API.”
ClearBooks, a top accounting software provider, exclusively offers a SOAP API, stressing the protocol’s importance in secure and complex financial data transactions.”

Let’s deep dive into how to consume or implement any SOAP-based API in ASP.NET Core (.NET 8).

How to Create SOAP Web Service Using WSDL in Visual Studio .NET Core

Creating a SOAP web service WSDL in Visual Studio ASP.NET Core (.NET 8)

    1. Launch Visual Studio 2026 on your machine.

      To use the code examples provided in this article you need to have Visual Studio 2022 installed on your system. If you do not already have a copy of Visual Studio 2022 you can download Visual Studio 2022 from the website, not Visual Studio 2026 because the code examples are meant for Visual Studio 2022    meant for Visual Studio 2022.

      Visual Studio 2026 Dashboard
    2. Create a New Project.

      Navigate to “File” > “New” > “Project…”

      Choose the appropriate project template, such as “ASP.NET Core WebAPI.”

      Create new project ASP.NET Core WebAPI
    3. Set up the Project in ASP.NET Core Web API and configure project settings, including the project name and location.

      Visual Studio 2026 configure new ASP.NET Core Web API project screen with project name field highlighted
    4. Install the SoapCore package.

      After creating your Web API project in Visual Studio, incorporate the SoapCore NuGet package into it. Follow these steps:

      • Navigate to the Solution Explorer window,
      • Choose the project,
      • right-click, and opt for “Manage NuGet Packages”.

      In the NuGet Package Manager window, locate the SoapCore package , then install it.

      You can also get the SoapCore package by using the NuGet Package Manager console. To start installing it you need to type in a command. The command you need to type is the one that starts the installation of the SoapCore package.
    5. Define the Data Contract.

      In the data contract, we define the characteristics of each SoapService data type, such as their types, names, and any rules or restrictions.

      This ensures that clients and services built with different programming languages or platforms can communicate effectively.

      
      namespace SoapService.Models
      {
          public class CustomerDataContract
          {
              [DataContract]
              public class Author
              {
                  [DataMember]
                  public int Id { get; set; }
      
                  [DataMember]
                  public string FirstName { get; set; }
      
                  [DataMember]
                  public string LastName { get; set; }
      
                  [DataMember]
                  public string EmailAddress { get; set; }
              }
          }
      }
      
    6. Define the Service Contract

      A service contract is made up of two parts. The service interface is one part. It tells us what the service does. The other part has details like how messages are formatted and how security works. We use something called the ServiceContract attribute in C# to define all of this. This ServiceContract attribute is like a label that we put on an interface or class to say that it is a service contract. The ServiceContract attribute is important because it marks the interface or class as a service contract, in C#.

      The ServiceContract attribute is really important because it marks the interface or the class as a ServiceContract in C#. This is how we use the ServiceContract attribute to make it clear that something is a ServiceContract. The ServiceContract attribute is what makes this work, in C#.

      
      namespace SoapService.Models
      {
          public class CustomerServiceContract
          {
              [ServiceContract]
              public interface ICustomerService
              {
                  [OperationContract]
                  CustomerDataContract GetCustomers();
              }
          }
      }
        
    7. Create a service and add a method to the service with customer data.

      
      namespace SoapService.Services
      {
          public class CustomerService : ICustomerService
          {
              public CustomerDataContract GetCustomers()
              {
                  return new CustomerDataContract
                  {
                      Id = 1,
                      FirstName = "John",
                      LastName = "Doe",
                      EmailAddress = "john.doe@example.com"
                  };
              }
          }
      }
      
    8. Register a SOAP service in the Program.cs (.NET 8 Format)

      
        builder.Services.AddSingleton<ICustomerService, CustomerService>();
      
    9. Configure the HTTP request pipeline for the SOAP endpoint in Program.cs

      
      app.UseSoapEndpoint<ICustomerService>("/CustomerService.asmx", new SoapEncoderOptions());
      
    10. Complete the source code of the Program.cs

      
      using SoapCore;
      using SoapService.Services;
      using static SoapService.Models.CustomerServiceContract;
      
      var builder = WebApplication.CreateBuilder(args);
      
      // Add services to the container.
      builder.Services.AddSingleton<ICustomerService, CustomerService>();
      builder.Services.AddControllers();
      var app = builder.Build();
      
      // Configure the HTTP request pipeline.
      app.UseSoapEndpoint<ICustomerService>("/CustomerService.asmx", new SoapEncoderOptions());
      
      app.UseHttpsRedirection();
      app.UseAuthorization();
      app.MapControllers();
      app.Run();
      
      
    11. Run the SOAP service.

      Launch the application and visit the specified endpoint to view the generated WSDL.

ASP.NET SOAP web service XML response displayed in browser at localhost showing WSDL definitions
SOAP GetCustomers request and response XML shown in SoapUI for ASP.NET ASMX web service

Consume WSDL in .NET 8

Create a .NET Core (.NET 8) WEB API project, same as shown in the above step.

Create client applications to consume the SOAP service. Visual Studio can help generate client code from the WSDL.

  1. Generate reference code from a WSDL file. Right-click on “Manage Connected Services.”

    Visual Studio Manage Connected Services option in ASP.NET Core project to add SOAP service reference
  2. Click on “Add a service reference.”

    Screenshot of a software interface displaying "Connected Services" with options for adding a service dependency or reference, featuring a highlighted "Add a service reference" link for integrating SOAP web services.
  3. Select “WCF Web Service“

    Select WCF Web Service option in Visual Studio to add SOAP service reference in ASP.NET Core
  4. Insert the WSDL URI

    Click “Go,” and you’ll receive a list of services, methods, and a Namespace. Use this Namespace to reference methods in the project.

    Enter WSDL URL and select GetCustomers operation while adding WCF service reference in Visual Studio
  5. Clicking “Next” allows configuration,

    such as specifying the type of collections to generate. In this example, we’ll choose System.Collections.Generic.List.

    WCF service reference data type options in Visual Studio with reuse types in referenced assemblies selected
  6. In the final configuration screen,

    Choose between public/private classes and opt for synchronous or default asynchronous method generation.

    Generate synchronous operations option while adding WCF SOAP service reference in Visual Studio
  7. Click “Finish” to initiate scaffolding, and your classes will be generated.

    WCF SOAP service reference successfully added in Visual Studio showing configuration progress complete
  1. Once the process is complete,

    Find the connected service in the Solution Explorer, containing the generated reference with configured endpoints and methods.

    Choosing a synchronous method generates various available methods.

    Screenshot of code in an IDE showing highlighted sections for the methods GetCustomers() and GetCustomersAsync() in CustomerDataContract and ICustomerService files, illustrating their integration with a SOAP web service.
  2. Create a new controller.

    To illustrate how to utilize the recently established connected service using the SOAP Client.

    To communicate with the connected service, create a client by referencing the Customer Reference. Indicate the endpoint to be used in the client.

    
    [ApiController]
    [Route("CustomerController")]
    public class CustomerController : Controller
    {
        [HttpGet]
        public async Task<CustomerDataContract> GetCustomersAsync()
        {
            ICustomerService customerService =
                new CustomerServiceClient(CustomerServiceClient.EndpointConfiguration.BasicHttpBinding_ICustomerService);
    
            return await customerService.GetCustomersAsync();
        }
    }
    

  3. Execute the project and perform testing in Swagger.

    Swagger UI testing ASP.NET Core API endpoint consuming WCF SOAP service with JSON response

Conclusion

Using Visual Studio to make a SOAP service with WSDL is really easy. It helps you make web services that work well with systems and follow standards.

If you follow these steps you can make a SOAP service. Define what it does. Then you can easily add it to your projects.

Just keep in mind that you need to adjust these steps to fit your project and the version of Visual Studio you have. You should use SOAP service when you need to make a SOAP service and WSDL is good, for defining what your SOAP service does.

Stay with us for more tips and tricks about the ASP.NET Core (.NET 8)Development concept.

I hope you will like my blog to help provide a firm foundation for building interoperable and standardized web services.

You can share this blog via a social button to help other ASP.NET Developers. As we are at Satva Solutions, we provide API integration services for any ASP.NET MVC/Core application.

Happy coding!

Next, read this:

FAQs

What is WSDL in C#?
WSDL (Web Services Description Language) defines the structure of a SOAP web service, including operations, inputs, outputs, and endpoints used in C# applications.
How do you call a SOAP web service in C#?
You can call a SOAP web service in C# by adding a service reference in Visual Studio or using HttpClient to send XML-based SOAP requests.
Does ASP.NET Core support SOAP services?
ASP.NET Core does not natively support SOAP like WCF, but SOAP services can be implemented using libraries like CoreWCF or SoapCore.
Does .NET 8 support SOAP web services?
Yes, .NET 8 supports SOAP web services through external libraries such as SoapCore and CoreWCF for building and consuming SOAP APIs.
How do I generate a client proxy from a WSDL in .NET 8?
You can generate a SOAP client proxy in .NET 8 using Visual Studio Connected Services or the dotnet-svcutil CLI tool.
What is the difference between SOAP and REST?
SOAP is a protocol-based API standard that uses XML and WSDL, while REST is an architectural style that commonly uses JSON and HTTP methods.
When should you use SOAP instead of REST?
SOAP is preferred in enterprise applications that require strict security, formal contracts, and reliable transaction handling.
How do I secure a SOAP service in ASP.NET Core?
To secure a SOAP service in ASP.NET Core, enforce HTTPS, implement authentication and authorization, and follow standard API security practices.

Article by

Jignasha Rathod

Jignasha Rathod is a Technical Analyst with over a decade of experience in the IT industry. She excels in .NET, CI/CD, GitHub, Azure. and has a proven track record in project management, leadership, API integrations, and Azure AI and ML.net . Jignasha is focused on performance enhancement and possesses deep domain expertise in open source CMS ( umbraco, orchard cms ) accounting, CRM, ERP (SAP, NetSuite, Business Central) and e-commerce. Her extensive experience spans across both B2B and B2C e-commerce platforms, and she is leveraging AI and ML technologies to drive innovation and efficiency in client projects.