SoapCore 服务始终返回 WSDL

SoapCore service always returns WSDL

提问人:James 提问时间:11/5/2023 更新时间:11/5/2023 访问量:23

问:

我有一个简单的 SoapCore 服务,其中指定了一些方法。当我加载 ASMX 页面时,它显示了 WSDL,但我希望显示一个 UI,我可以从中调用 Web 服务方法

这是我的服务合同的一部分

namespace QBCoreSOAPService
{
    [ServiceContract]
    public interface IAuthorService
    {
        [OperationContract]
        void MySoapMethod(XElement xml);

        [OperationContract]
        string getInteractiveURL(string wcTicket, string sessionID);

        [OperationContract]
        string interactiveRejected(string wcTicket, string reason);

这是我服务的一部分

public class AuthorService : IAuthorService
{
    System.Diagnostics.EventLog evLog = new System.Diagnostics.EventLog();
    public int count = 0;
    public AuthorService() 
    {
        //CODEGEN: This call is required by the ASP.NET 
        //Web Services Designer
        InitializeComponent();
        // Initializing EventLog for logging
        initEvLog();
    }
    private void InitializeComponent()
    {
    }
    public void MySoapMethod(XElement xml)
    {
        Trace.WriteLine(xml.ToString());
    }
    public string getInteractiveURL(string wcTicket, string sessionID)
    {
        return "";
    }

下面是 Program.cs 文件

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection.Extensions;
using QBCoreSOAPService;
using SoapCore;
using System.ServiceModel;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddSoapCore();
builder.Services.TryAddSingleton<AuthorService>();
builder.Services.AddMvc();
var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
    endpoints.UseSoapEndpoint<IAuthorService>("/WCWebService.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
});

app.MapRazorPages();

app.Run();

当我调用/加载 WCWebService.asmx 时,显示 wsdl。但相反,我希望有实际的 GUI 来显示我可以从中调用 Web 服务方法

谢谢advane的每个人

C# SOAP WSDL ASMX SOAPCore

评论


答: 暂无答案