Consume Calculator Service

Welcome to the part-2 of WCF…Run your service and copy the address which is available in WCF Test Client which is shown as:
Now create a new console Application as shown:
Right Click References in Solution and select Add Service Reference which populates a new window with entries as Address where you need to paste the address of your Calculator service which was copied in Very first step then click GO button and give a name to it as shown:
Serviceref Click on OK..Now client console application have a proxy service in it..just create a object of it then access its operation contracts by supplying required parameter values and get the result..sample of such code is shown as: code Just press Clrl+F5 then supply the values..

the final output would be as shown:



Now the same Calculator service we now going to consume in windows Application..

1. Create new windows application using C# language and name as Windows_Calculator.

2. Add service reference by right click on  solution and paste the URL of the service in Address bar as we did in console application above in two images and press discover button.

3. create the service_reference object and access their methods and code as shown in below image:


one thing we need to observe here is that we are not at all writing any logic code here in consuming clients because all logic is written in service and we just pass appropriate input and retrieve the results.The output of the above windows application would be as:


Hope would be helpful for anyone atleast…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s