7
votes

I want to consume a WCF service in my .NET Core application without adding service reference?

I am able to consume WCF by installing WCF connected service and adding service reference but I don't want to add any service reference.

3
Create it by hand? :P - Tseng
Use ChannelFactory<T> from System.ServiceModel github.com/dotnet/wcf/tree/master/src/… - tom redfern

3 Answers

2
votes

Please refer to the follow link. It has some minors issues, but is easy to fix.

Calling Web Method Without a Service Reference

1
votes

if you are using wcf service then you can expose it as a restful service. then you can simply consume it. actully i have been use it for many years and its been really useful. here you can read more about that: REST / SOAP endpoints for a WCF service

-2
votes

you can create a service proxy using svcutil.exe and use the proxy class as a reference.

here is a sample:

SvcUtil.exe http://www.temperatureservice.com:8080/TemperatureService.svc /ser:DataContractSerializer /s /language:cs  /out:TemperatureServiceProxy.cs  /n:*,WCF.Client.Proxies.Proxy

It will generate TemperatureServiceProxy.cs file, include this file in your project and create a service client by referencing this file.