Create SOAP Web Service in DOTNET Core

In this article, I’m going to demonstrate development of SOAP WebService using .Net Core. We will utilize a NutGet package available for SoapCore. Pros of using this we will reuse features like filter and routing.


We will create an Empty Project you can use your preferred Visual Studio IDE. In this case I’m using dotnet cli to create an empty project using this command.

dotnet new web

Install SoapCore Nuget package with the following command

dotnet add package SoapCore

On successful installation of Nuget package, create a new Folder at the root of the project for Models.


Create a new File in the Models folder with the name as MachineModel.cs and add the below code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;namespace TempWSDL.Models
{   [DataContract]
    public class MachineModel
    {
        [DataMember]
        public int Id { get; set; }
        
       [DataMember]
        public string MachineName { get; set; }       

        [DataMember]
        public string HorsePower { get; set; }
    }
}

Create another folder Services as the name, inside this create an Interface IAccelerationService.cs and add the below code

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Threading.Tasks;namespace TempWSDL.Models
{
    [ServiceContract]
    public interface IAccelerationService
    {
        [OperationContract]
        string Speed(string s);        

        [OperationContract]
        void XmlMethod(System.Xml.Linq.XElement xml);
        [OperationContract]
        MachineModel TestMachine(MachineModel machine);    
    }
}

Create AccelerationService.cs class under the Services folder and add the below code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using TempWSDL.Models;namespace TempWSDL.Services
{
    public class AccelerationService : IAccelerationService