Can not set session data using SoapCore with XMLSerializer in net 7

48 Views Asked by At

when i try to migrate asmx to net 7 used Soap Core 1.1

The session is not working , below are sample code call from client. The Test function will set a string in session and TestCustomModel suppose to get back the string from session in Name property.

//client code by web reference to service.asmx

var sampleService = new SampleService();

sampleService.Url = "http://xxxx/service.asmx";

var actual = sampleService.Test("testing..");

var testCustomModel = sampleService.TestCustomModel(new MyCustomModel());

But the testCustomModel.Name is null

//program.cs

using Corvus.WebServices;

using SoapCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDistributedMemoryCache();

builder.Services.AddSession((options =\>

{

options.Cookie.HttpOnly = true;

options.Cookie.IsEssential = true;

}));

builder.Services.AddSoapCore();

builder.Services.AddSingleton\<ISampleService, SampleService\>();

builder.Services.AddSingleton\<IHttpContextAccessor, HttpContextAccessor\>();

builder.Services.AddRazorPages();

var app = builder.Build();

app.UseRouting();

app.UseSession();

app.UseEndpoints(endpoints =\> {

endpoints.UseSoapEndpoint\<ISampleService\>("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer,true);

});
0

There are 0 best solutions below