Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add service reference in client project?

Tags:

c#

wcf

wcf-client

I am totally new to WCF so please indicate if you find something that I am doing totally wrong here. I have created a WCF service project (my service class is dervied from ServiceBase class) with endpoint address binding set to basicHttpBinding. Now I need to create a client application that can call some APIs from this service. My quesion is that in my client application how can I add service reference to that service. Do I need to publish this service first under IIS (which mean I have to have IIS available on the machine too) or is there some other way of adding service reference too.

like image 329
Silverlight Student Avatar asked Jan 20 '23 08:01

Silverlight Student


2 Answers

You need something to be running the service, with the metadata being published. This can be IIS, but also any other valid hosting option.

I often write a simple console application to self-host a WCF service, exactly for this reason. It makes it super easy to debug, as well as to update service references during the earlier phases of development, and can dramatically simplify work when working on the client and server simultaneously.

like image 109
Reed Copsey Avatar answered Jan 24 '23 23:01

Reed Copsey


You don't have to publish it under IIS, with WCF you can host your sevice in a console application or windows forms app or as Windows service or under IIS.

In your client app you will just need to right click and add service reference.

update:
Simple WCF Example

like image 36
Jethro Avatar answered Jan 24 '23 22:01

Jethro