How to use soapcore in asp net core project for exposing wsdl at project route f


ASP.NET is a popular programming language used for building web applications. One of the key features of ASP.NET is its ability to SOAP-based web services using the SOAPCore library. In this article, we will explore how to use SOAPCore in an ASP.NET Core project to expose a WSDL at the project route.

Setting up the ASP.NET Core Project

Before we dive into using SOAPCore, let's first set up an ASP.NET Core project. Open your preferred development and create a new ASP.NET Core project. You can use the command to create a new project:

dotnet new web -n MySoapProject

This command will create a new ASP.NET Core project named “MySoapProject”. Navigate to the project directory using the following command:

cd MySoapProject


Next, we need to install the SOAPCore library in our project. SOAPCore is a lightweight SOAP library for ASP.NET Core. To install SOAPCore, run the following command:

dotnet add package SoapCore

This command will add the SOAPCore package to your project, allowing you to use its features.

Exposing a WSDL at Project Route

Now that we have our ASP.NET Core project set up and SOAPCore installed, let's proceed to expose a WSDL at the project route. To do this, we need to define a SOAP service and configure the SOAP endpoint.

First, let's create a new called “MySoapService” that implements the SOAP service interface. This class will contain the methods that will be exposed as SOAP operations. Here's an example:

public class MySoapService : IMySoapService
    public string HelloWorld()
         "Hello, !";

In this example, we have a method called “HelloWorld” that returns a greeting message.

Next, we need to configure the SOAP endpoint in the “Startup.cs” file. Open the “Startup.cs” file and add the following code inside the “ConfigureServices” method:


This code configures the SOAPCore services in the ASP.NET Core dependency injection container.

Next, add the following code inside the “Configure” method in the “Startup.cs” file:

This code adds a SOAP endpoint at the “/soap” route, exposing the methods defined in the “MySoapService” class as SOAP operations.

Testing the SOAP Service

Now that we have exposed the SOAP service, let's test it. Run the ASP.NET Core project using the following command:

dotnet run

Once the project is running, open your web browser and navigate to “http://localhost:5000/soap?wsdl”. This will display the WSDL for the SOAP service.

You can also test the SOAP operations using a SOAP client tool like SoapUI or by SOAP requests .


In this article, we have explored how to use SOAPCore in an ASP.NET Core project to expose a WSDL at the project route. We have seen how to set up an ASP.NET Core project, install SOAPCore, define a SOAP service, configure the SOAP endpoint, and test the SOAP service. SOAPCore provides a simple and lightweight way to expose SOAP-based web services in ASP.NET Core projects.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents