SlideShare a Scribd company logo
1 of 3
Download to read offline
Windows Communication Foundation (WCF) using Visual Studio
2013
Now, let us see how to create simple WCF to do simple mathematical calculations.
I am using Visual Studio 2013 to create this project.
1. Invoke Visual Studio
2. Select New Project
3. Under Installed templates, choose Web → WCF → WCF Service Application
4. Give a name to this project. I have named this project as mathematics
5. Press OK button
6. Now, from Solution Explorer window, delete IService1.cs and Service1.cs files. See
the below picture.
7. Now, Right click on your project – Mathematics
8. Select Add → New Item →WCF Service
9. Give some name to this service. I have names it as maths. Notice that Imaths.cs and
maths.cs files created automatically and you can see them from the Solution
Explorer window.
10. Now open Imaths.cs file by double clicking on it
11. Look for void DoWork() method. Remove this method and add two methods add
and sub to return addition and subtraction of two numbers as shown (see the next
page)
Delete
these files
12. Now, open maths.cs file double clicking on that file
13. Remove method public void DoWork() method. In its place add the code as shown
below:
14. Like asmx web services, here too you can build this code and test by selecting Build
→ Build Solution option. Try it yourself an check whether system displays any error
messages or not.
15. You can also run these programs by clicking on Start button. Try it yourself.
Consuming WCF methods from
Now, let us see how to consume the above created methods from a web page.
1. Click on Project – Mathematics.
2. Select Add → New Item → Web Form. Give some name to this webform. I named it
as calculate
3. Change to Design mode
4. Add a Button to this form.
5. Double Click on the button
6. In the Button_click event, add the following codes.
7. Now, run the web page to display the sum and difference of 200 and 100.
Try it yourself:
- Instead of passing hard coded values 200 and 100, please add two textboxes in the
webform so that users can enter two numerical values at runtime.
- BK Dharmaraju, Bangalore, India – has around 30 years of
experience in the field of IT.

More Related Content

What's hot (8)

Providing sl no in Gridview in Dot Net
Providing sl no in Gridview in Dot NetProviding sl no in Gridview in Dot Net
Providing sl no in Gridview in Dot Net
 
Add contacts
Add contactsAdd contacts
Add contacts
 
Admin Habits & Hacks Handout - Salesforce World Tour Boston
Admin Habits & Hacks Handout - Salesforce World Tour BostonAdmin Habits & Hacks Handout - Salesforce World Tour Boston
Admin Habits & Hacks Handout - Salesforce World Tour Boston
 
Visual studio 2012
Visual studio 2012Visual studio 2012
Visual studio 2012
 
Testing
TestingTesting
Testing
 
Maintenance Reporting Website
Maintenance Reporting WebsiteMaintenance Reporting Website
Maintenance Reporting Website
 
Microsoft office access 2003
Microsoft office access 2003Microsoft office access 2003
Microsoft office access 2003
 
Entity frame work by Salman Mushtaq -1-
Entity frame work by Salman Mushtaq -1-Entity frame work by Salman Mushtaq -1-
Entity frame work by Salman Mushtaq -1-
 

Similar to Windows Communication Foundation (WCF) programming using Visual Studio

Oracle apex hands on lab#2
Oracle apex hands on lab#2Oracle apex hands on lab#2
Oracle apex hands on lab#2
Amit Sharma
 
Cis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry universityCis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry university
lhkslkdh89009
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
lhkslkdh89009
 
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
WithTheBest
 
Diving into VS 2015 Day1
Diving into VS 2015 Day1Diving into VS 2015 Day1
Diving into VS 2015 Day1
Akhil Mittal
 
windows azure cloud services - Lab Manual
windows azure cloud services - Lab Manualwindows azure cloud services - Lab Manual
windows azure cloud services - Lab Manual
Arun Kumar
 

Similar to Windows Communication Foundation (WCF) programming using Visual Studio (20)

Web services in asp.net
Web services in asp.netWeb services in asp.net
Web services in asp.net
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
Oracle apex hands on lab#2
Oracle apex hands on lab#2Oracle apex hands on lab#2
Oracle apex hands on lab#2
 
Cis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry universityCis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry university
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
 
Installing Process Oracle 10g Database Software on Windows 10
Installing Process Oracle 10g Database Software on Windows 10Installing Process Oracle 10g Database Software on Windows 10
Installing Process Oracle 10g Database Software on Windows 10
 
Class1_Lab2 (14).pdf
Class1_Lab2 (14).pdfClass1_Lab2 (14).pdf
Class1_Lab2 (14).pdf
 
CIS 170 Inspiring Innovation/tutorialrank.com
 CIS 170 Inspiring Innovation/tutorialrank.com CIS 170 Inspiring Innovation/tutorialrank.com
CIS 170 Inspiring Innovation/tutorialrank.com
 
Azure Devops
Azure DevopsAzure Devops
Azure Devops
 
CIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comCIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.com
 
SCCM2012-UserGuide
SCCM2012-UserGuideSCCM2012-UserGuide
SCCM2012-UserGuide
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
 
Diving into VS 2015 Day1
Diving into VS 2015 Day1Diving into VS 2015 Day1
Diving into VS 2015 Day1
 
Microsoft VS C++ Add a project
Microsoft VS C++ Add a projectMicrosoft VS C++ Add a project
Microsoft VS C++ Add a project
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
windows azure cloud services - Lab Manual
windows azure cloud services - Lab Manualwindows azure cloud services - Lab Manual
windows azure cloud services - Lab Manual
 

More from Dharma Raju (8)

Master slave control in gridview
Master   slave control in gridviewMaster   slave control in gridview
Master slave control in gridview
 
Change row colour based on some condition
Change row colour based on some conditionChange row colour based on some condition
Change row colour based on some condition
 
Popup confirmation for Delete Button in GridView
Popup confirmation for Delete Button in GridView Popup confirmation for Delete Button in GridView
Popup confirmation for Delete Button in GridView
 
How to add sorting and pagers to grid view
How to add sorting and pagers to grid viewHow to add sorting and pagers to grid view
How to add sorting and pagers to grid view
 
How to add sql server table into dot net web page (Gridview)
How to add sql server table into dot net web page (Gridview)How to add sql server table into dot net web page (Gridview)
How to add sql server table into dot net web page (Gridview)
 
Internal tables in sap
Internal tables in sapInternal tables in sap
Internal tables in sap
 
Govina haadu
Govina haaduGovina haadu
Govina haadu
 
Coffee
CoffeeCoffee
Coffee
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Windows Communication Foundation (WCF) programming using Visual Studio

  • 1. Windows Communication Foundation (WCF) using Visual Studio 2013 Now, let us see how to create simple WCF to do simple mathematical calculations. I am using Visual Studio 2013 to create this project. 1. Invoke Visual Studio 2. Select New Project 3. Under Installed templates, choose Web → WCF → WCF Service Application 4. Give a name to this project. I have named this project as mathematics 5. Press OK button 6. Now, from Solution Explorer window, delete IService1.cs and Service1.cs files. See the below picture. 7. Now, Right click on your project – Mathematics 8. Select Add → New Item →WCF Service 9. Give some name to this service. I have names it as maths. Notice that Imaths.cs and maths.cs files created automatically and you can see them from the Solution Explorer window. 10. Now open Imaths.cs file by double clicking on it 11. Look for void DoWork() method. Remove this method and add two methods add and sub to return addition and subtraction of two numbers as shown (see the next page) Delete these files
  • 2. 12. Now, open maths.cs file double clicking on that file 13. Remove method public void DoWork() method. In its place add the code as shown below:
  • 3. 14. Like asmx web services, here too you can build this code and test by selecting Build → Build Solution option. Try it yourself an check whether system displays any error messages or not. 15. You can also run these programs by clicking on Start button. Try it yourself. Consuming WCF methods from Now, let us see how to consume the above created methods from a web page. 1. Click on Project – Mathematics. 2. Select Add → New Item → Web Form. Give some name to this webform. I named it as calculate 3. Change to Design mode 4. Add a Button to this form. 5. Double Click on the button 6. In the Button_click event, add the following codes. 7. Now, run the web page to display the sum and difference of 200 and 100. Try it yourself: - Instead of passing hard coded values 200 and 100, please add two textboxes in the webform so that users can enter two numerical values at runtime. - BK Dharmaraju, Bangalore, India – has around 30 years of experience in the field of IT.