How To Use WSDL File To Consume WCF Service in .NET Core Application?

 WCF Services play a pivotal role in modern day distributed application as all the requests from the UI Layer is passed on to the WCF Service API's which serve those requests appropriately. Lets see how we can consume the WCF Service by a .NET Core WPF application.

What is WSDL File?

WSDL Stands for Web Service Description Language, as the name suggests it gives a description of the functionality offered by the particular WCF service in a XML Format.

How to Download WSDL File?

WSDL file can be downloaded by going to the URL location where the WCF Service is hosted, 

For example:  

I have hosted the WCF Service locally identified by URL: http://localhost:6875/process

How to Configure Service Reference with the help of WSDL File?

Steps:

Step 1 :  enter this URL in a Web browser as shown below

Accessing WCF Service through Browser
Accessing WCF Service through Web browser


Step 2: Click on the link as highlighted in the below image

Accessing the WSDL file
Accessing the WSDL Content through the URL

Step 3: When you click on the link mentioned above you can see the WSDL content in the XML Format as shown below. Save the XML content with the extension .wsdl. Note you can give any name for the file.

WSDL File content
WSDL File Content


WSDL File
WSDL File


Step 4: Add this WSDL file to the .NET Core WPF Application by right clicking the project and navigate to Add Service Reference as shown below:

Adding WCF Service Reference
Adding Service Reference

Step 5: Add Service Reference Page opens up. Click on the Microsoft WCF Web Service Reference Provider, corresponding dialog opens up then click on Browse  and add the wsdl file which is being generated in the previous step.

Adding WSDL File as Service Reference
Adding WSDL File as Service Reference

Step 6: Click on Next and Finish the Process of Adding the service Reference. For me while adding the service reference I got an error related to .NET Core Runtime 2.1 is missing, So if you get the same error please install .NET Core Runtime appropriate version will be mentioned in the error message. This can be installed from Microsoft Site or from Visual Studio Installer page as shown below:

Installing .NET Core 2.1 Runtime
Installing .NET Core 2.1 Runtime

Step 7: Once the addition of Service Reference is successful you will see configured against the Microsoft WCF Web Service Reference Provider as shown  below:

Service Provider Configured
Service Reference Provider Configured

Now you will be able to use the Client class which is generated with the help of WSDL File by the framework. This Client class acts as a Proxy to communicate with the actual WCF Service. You will be able to see the contents of this Client class in  Reference.cs which is generated in the .NET Core Application.

Thanks for Reading. Do Share your valuable feedback in the comments below.
















 

Comments

Popular posts from this blog

Creating RESTful Minimal WebAPI in .Net 6 in an Easy Manner! | FastEndpoints

Step By Step Guide to Detect Heap Corruption in Windows Easily

How to dynamically add Properties in C# .NET?