如何使用.NET Core 2.0连接服务使用Web服务 [英] How to consume a web service using .NET Core 2.0 Connected Services

查看:61
本文介绍了如何使用.NET Core 2.0连接服务使用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为GetReportService的服务.我的端点是 http://xxx1/usa/report.asmx .我正在使用POST传递参数id123.

I have created a service called GetReportService. My endpoint is http://xxx1/usa/report.asmx. I am using POST passing a parameter id123.

如何在.NET Core 2.0中使用Web API调用此Web服务?

How do I invoke this web service using a web api in .NET Core 2.0?

推荐答案

我发现连接的服务选项是WCF服务,因此我可以像在.NET以前的版本中一样使用该服务.

I figured out that the connected service option is a WCF service so I am able to consume the service as I normally would in previous versions of .NET.

但是,在.NET Core中,如果要注入该服务,则必须转到Startup.cs文件并在ConfigureServices方法中添加我的服务,然后将该服务注入到我的控制器中.

However, in .NET Core if I want to inject that service, I do have to go to the Startup.cs file and add my service in the ConfigureServices method and then inject the service into my controller.

这是我所做工作的更详细说明:如何在ASP.Net核心中注入WCF服务客户端?

This is a more detailed explanation of what I did: How to inject WCF service client in ASP.Net core?

这篇关于如何使用.NET Core 2.0连接服务使用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆