netcore使用soapcore创建webservice
作者:互联网
好几年没搞webservice,因工作需要又重新搞起,.NET Framework版就太Low了,得与时俱进,netcore版搞起
1、使用Nuget包soapcore,创建接口类、实现类
namespace CLibrary_Soapcore.Interface { [ServiceContract] public interface IOpenHisService { [OperationContract] public NotifyResponse SendNotify(string notifyInfo); [OperationContract] public NotifyResponse OrderRefund(string notifyInfo); } }
namespace CLibrary_Soapcore.Imp { public class OpenHisService : IOpenHisService { public NotifyResponse OrderRefund(string notifyInfo) { return new NotifyResponse() { ResultCode = HisResultCode.SUCCESS, ResultDesc = "OrderRefund" }; } public NotifyResponse SendNotify(string notifyInfo) { return new NotifyResponse() { ResultCode = HisResultCode.SUCCESS, ResultDesc = "SendNotify" }; } } }
2、HTTP请求管道配置,及服务配置
var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton<IOpenHisService, OpenHisService>(); var app = builder.Build(); app.UseEndpoints(endpoints => { endpoints.UseSoapEndpoint<IOpenHisService> ("/OpenHisService.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); });
3、浏览器走起
标签:SendNotify,webservice,netcore,soapcore,notifyInfo,OrderRefund,NotifyResponse,pub 来源: https://www.cnblogs.com/zacklau/p/16640150.html