How to access WCF Service in Asp.Net Core Application

From Logic Wiki
Jump to: navigation, search

Installing WCF Connected Service Extension:

Below are the steps to install WCF Connected Service Extension in Asp.Net Core WebApplication

Right Click on the Connected Services Option Ser1.png

If the Extension is not installed then you will see the below window. User need to click on Find more Services link

Ser2.png

Extension and Updates window will be displayed and from this window you can find the Visual Studio WCF Connected Service extension option

Ser3.png

Click on Download button to install the extension. You may need to close the VisualStudio instances to complete the VSIX installation.


Accessing WCF Service in Asp.Net Core Web Application

In your Asp.Net Core web application, you will see a Connected Service Option like below

Ser1.png

Follow the below steps to Add Service Reference

  • Right Click on the Connected Services Option
  • Select Add Connected Service and Add Connected Services wizard will be displayed and Select the WCF -Service Preview option

Ser4.png

  • Click on the Configure button. This will bring up Configure WCF Service Reference dialog box. Enter your Service url and Click on Go or Discover, it will discover the

Ser5.png

  • Click on Next and select appropriate options

Ser6.png

  • Click on Finish to generate proxy for WCF Service.
  • Once after this you will be able to see Service Reference Folder added in our project.

Ser7.png

  • Now all you need to is to Create the Client and access the service like below
public async Task<IActionResult> Index()
        {
            //Creating Client object of Service Reference
            SimpleServiceReference.SimpleServiceClient client = new SimpleServiceReference.SimpleServiceClient();
            //Call the method from WCF Service
            string result = await client.GetDataAsync(1);
            return View();
        }

Result Ser8.png


https://aspdotnetcodehelp.wordpress.com/2017/03/27/how-to-access-wcf-service-in-asp-net-core-application/