Creating Soap Web-Service in .net core 6

1.6k Views Asked by At

I am trying to create a soap web service on .net core 6 by the use of the SoapCore nuget. I found this tutorial Link to site, but I am dealing with an Error.

Now im dealing with this Error: Argument 3: cannot convert from 'System.ServiceModel.BasicHttpBinding' to 'SoapCore.SoapEncoderOptions'

This is what I have added to my Startup.cs

builder.Services.AddSoapCore();
builder.Services.TryAddSingleton<ISampleService, SampleService>();
app.UseSoapEndpoint<ISampleService>("/Service.asmx",new BasicHttpBinding(), SoapSerializer.XmlSerializer);

The attribute: new BasicHttpBinding gives me the error I have mentioned above.

Heres the code from the tutorial:

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.TryAddSingleton<ISampleService, SampleService>();
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
      app.UseSoapEndpoint<ISampleService>("/Service.asmx", new BasicHttpBinding(), SoapSerializer.XmlSerializer);
        }
    }
1

There are 1 best solutions below

0
raq On

You should change the type from BasicHttpBinding to SoapEncoderOptions

the tutorial is using SoapCore

this is straing from their Readme /Getting Started :

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseRouting();

    app.UseEndpoints(endpoints => {
        endpoints.UseSoapEndpoint<ServiceContractImpl>("/ServicePath.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
    });
    
}