Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consuming a WCF service in .NET Core 2.0

I have a WSDL service which worked fine (and is still working in .net 4.x) and fairly newcomer to .NET Core 2.0.

I created the WSDL web service reference (The same steps followed as https://docs.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide)

My question is how to consume this service? Do someone know of a good tutorial? Any help would be greatly appreciated.

Thank you in advance

like image 501
Danie Du Preez Avatar asked Jun 07 '18 09:06

Danie Du Preez


People also ask

Can we consume WCF service in .NET Core?

You cannot "host" or have a ASP.NET Core app that implements a WCF service, but you can "consume" WCF services.

How do you consume WCF service?

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.

How can I take WCF service without adding references?

Right click on the Solution Explorer of "WCFDemo" and go to Add > New Project. In the "New Project" dialog box, under Project types, expand Visual C#, and then click on WCF. Select "WCF Service Application" and in the Name box, type "WCFService". Click "OK".

Which .NET framework supports WCF?

Starting with . NET Framework 4.5, WCF provides an easier way to configure both self-hosted and web hosted services in code.


1 Answers

My question is how to consume this service?

The WCF Web Service Reference Provider Tool creates everything you need.

The client is automatically created with all the end-points in the service and any associated classes such as service parameters.

During the WCF Web Service Reference Provider Tool wizard you specify a namespace for the client, so if you entered CompanyName.Service you'd be able to create the client by typing var client = new CompanyName.Service.ClientName();

Please note that the name ClientName will be generated by the tool, and intelli-sense will you give you the actual name.

Once you have the client you can call any method on the service in the normal way. Such as:

var response = client.CancelPolicyAsync(cancelRequest);
like image 57
Joe Ratzer Avatar answered Nov 15 '22 09:11

Joe Ratzer