使用从WSDL自动生成的代码调用Web服务

我正在尝试制作一个与外部API集成的应用程序。外部API的提供者给了我一个WSDL文件,我使用它来使用microsoft WCF Web服务参考提供程序(参考this guide)自动生成一些代码。现在,我的项目结构如下图所示:

使用从WSDL自动生成的代码调用Web服务

Startup.cs如下所示:

    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application,visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/",async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            });
        }
    }

由WSDL生成的代码位于Reference.cs中,因为包含了我确定他们不想发布的信息,所以我不会在此处发布。但是,它确实包含一堆用于不同功能的端点,每个端点都有一些参数。我的问题是,如何去调用这些不同的端点?我猜想在Startup.cs中更改app.UseEndpoints,但是如何为多个端点配置它呢?而我用await context.Response.WriteAsync("Hello World!");替换什么?

这最终有点混乱,但是基本上我只想将一些参数传递给这些不同的端点。

linlin1988124 回答:使用从WSDL自动生成的代码调用Web服务

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3158664.html

大家都在问