SlideShare a Scribd company logo
https://www.csharp.com/UploadFile/29d7e0/steps-to-create-a-simple-web-service-and-use-it-in-
Asp-Net/
STEP:1 CREATE YOUR OWN Web Service using
1. File > New > Website… >> ASP.NET Empty Website (Visual C#) [TempWebService]
2. In Solution Explorer -> Right click on Project Name -> Add New Item
3. Give Name to this web service “CalcWebService” (CalcWebService.asmx)
4. Open code Window of the CalcWebService (CalcWebService.cs) and write a
[WebMethod] name Multi() (Code is given below)
5. Test the web service by F5 (Run).
Create A
CalcWebService.asmx
(Keep default page as it is)
<%@ WebService Language="C#" CodeBehind="~/App_Code/Calcwebservice.cs"
Class="Calcwebservice" %>
CalcWebService.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
/// <summary>
/// Summary description for Calcwebservice
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET
AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Calcwebservice : System.Web.Services.WebService {
public Calcwebservice () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public int multi(int a, int b)
{
return a * b;
}
}
STEP:2 - DEPLOY the WEB SERVICE in IIS server
1) Check the IIS webserver is running or not by writing LOCALHOST in the Browser
2) If not than Go to IIS Manager
3) Open it write click on the IIS server name if not Started → press Start
4) Refresh the “Default Web Site”, you will get your web service folder
“TempWebService” from the c:inetpubwwwroot.
5) Now Right Click on “TempWebService” and click on “Convert to Application”
6) After that, to publish the web service, Go to the IIS → “Directory Browsing” and
make it ENABLED.
7) Now in right hand panel, you will find Browse-80, Click on it and test the web service
in browser. Keep the URI copy for next step of ClientApp development.
STEP:3 Create a Client App, Add Web Reference and Use it in the Client
App to call Web Service
Create Website with Default.aspx at C:inetpubwwwrootmyCalculator
<%@ Page Title="Home Page" Language="C#"
MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server"
ContentPlaceHolderID="HeadContent">
<style type="text/css">
.style1
{
font-size: medium;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent">
<h2>
Welcome to ASP.NET!
</h2>
<p>
<asp:Label ID="Label1" runat="server" style="font-size:
medium">First No.</asp:Label>
<asp:TextBox ID="t1" runat="server"
CssClass="style1"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label2" runat="server" style="font-size:
medium"
Text="Second No."></asp:Label>
<asp:TextBox ID="t2" runat="server"
CssClass="style1"></asp:TextBox>
</p>
<p>
<asp:Button ID="btnMulti" runat="server" Text="MULTI"
onclick="btnMulti_Click" />
<asp:Label ID="lblResult" runat="server" style="font-size:
medium"></asp:Label>
</p>
</asp:Content>
using System;
using myCalc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnMulti_Click(object sender, EventArgs e)
{
int a, b, c;
a = Convert.ToInt32(t1.Text);
b = Convert.ToInt32(t2.Text);
Calcwebservice obj = new Calcwebservice();
c= obj.multi(a, b);
lblResult.Text = c.ToString();
}
}

More Related Content

PDF
Web services in asp.net
PPTX
Creating & consuming simple web service
PPTX
Parallelminds.asp.net web service
PPT
Bespoke Digital Media - Web
DOCX
KO on Web Services
PPT
Web services intro.
DOC
Create Applicationwith IIS 7
DOCX
To create a web service
Web services in asp.net
Creating & consuming simple web service
Parallelminds.asp.net web service
Bespoke Digital Media - Web
KO on Web Services
Web services intro.
Create Applicationwith IIS 7
To create a web service

Similar to ASP.NET 2010, WebServices Full Example for BCA Students (20)

PPT
Deploy and Publish Web Service
PDF
Windows Communication Foundation (WCF) programming using Visual Studio
DOC
Sharepoint 2010 content
PPTX
Web services
PPT
Microsoft Tech Ed 2006 #1
PDF
TERMINALFOUR t44u 2012 - Web services
PPTX
01 introduction to wad.pptx
PPT
.Net Project Portfolio for Roger Loving
PDF
ASP.NET Overview - Alvin Lau
PPT
Synapse india dotnet development web approch
PPTX
Development of Web Services for Android Applications
PPT
Espositoajaxremote 1210732828647866-8
PPT
Synapse india reviews sharing chapter 23 – asp.net-part2
PDF
Asp.net
DOC
java Developing using asp.net
PPSX
16 asp.net session23
PPT
DOC
QuickConnect
DOC
Web application using c# Lab - Web Configuration file
Deploy and Publish Web Service
Windows Communication Foundation (WCF) programming using Visual Studio
Sharepoint 2010 content
Web services
Microsoft Tech Ed 2006 #1
TERMINALFOUR t44u 2012 - Web services
01 introduction to wad.pptx
.Net Project Portfolio for Roger Loving
ASP.NET Overview - Alvin Lau
Synapse india dotnet development web approch
Development of Web Services for Android Applications
Espositoajaxremote 1210732828647866-8
Synapse india reviews sharing chapter 23 – asp.net-part2
Asp.net
java Developing using asp.net
16 asp.net session23
QuickConnect
Web application using c# Lab - Web Configuration file
Ad

More from Jainul Musani (20)

PDF
Core Java Interface Concepts for BCA Studetns
PDF
Java Abstract and Final Class for BCA students
PDF
Java Collection Framework for BCA Students
PDF
Simple Calculator using JavaFx a part of Advance Java
PDF
JavaFx Introduction, Basic JavaFx Architecture
PDF
Palindrome Programme in PHP for BCA students
PDF
Leap Year Program in PHP for BCA students
PDF
"PHP and MySQL CRUD Operations for Student Management System"
PDF
Python: The Versatile Programming Language - Introduction
PPTX
Python a Versatile Programming Language - Introduction
PDF
React js t8 - inlinecss
PDF
React js t7 - forms-events
PDF
React js t6 -lifecycle
PDF
React js t5 - state
PDF
React js t4 - components
PDF
React js t3 - es6
PDF
React js t2 - jsx
PDF
React js t1 - introduction
PPTX
ExpressJs Session01
PPTX
NodeJs Session03
Core Java Interface Concepts for BCA Studetns
Java Abstract and Final Class for BCA students
Java Collection Framework for BCA Students
Simple Calculator using JavaFx a part of Advance Java
JavaFx Introduction, Basic JavaFx Architecture
Palindrome Programme in PHP for BCA students
Leap Year Program in PHP for BCA students
"PHP and MySQL CRUD Operations for Student Management System"
Python: The Versatile Programming Language - Introduction
Python a Versatile Programming Language - Introduction
React js t8 - inlinecss
React js t7 - forms-events
React js t6 -lifecycle
React js t5 - state
React js t4 - components
React js t3 - es6
React js t2 - jsx
React js t1 - introduction
ExpressJs Session01
NodeJs Session03
Ad

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”

ASP.NET 2010, WebServices Full Example for BCA Students

  • 1. https://www.csharp.com/UploadFile/29d7e0/steps-to-create-a-simple-web-service-and-use-it-in- Asp-Net/ STEP:1 CREATE YOUR OWN Web Service using 1. File > New > Website… >> ASP.NET Empty Website (Visual C#) [TempWebService] 2. In Solution Explorer -> Right click on Project Name -> Add New Item 3. Give Name to this web service “CalcWebService” (CalcWebService.asmx) 4. Open code Window of the CalcWebService (CalcWebService.cs) and write a [WebMethod] name Multi() (Code is given below) 5. Test the web service by F5 (Run).
  • 2. Create A CalcWebService.asmx (Keep default page as it is) <%@ WebService Language="C#" CodeBehind="~/App_Code/Calcwebservice.cs" Class="Calcwebservice" %> CalcWebService.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; /// <summary> /// Summary description for Calcwebservice /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Calcwebservice : System.Web.Services.WebService { public Calcwebservice () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public int multi(int a, int b) { return a * b; } }
  • 3. STEP:2 - DEPLOY the WEB SERVICE in IIS server 1) Check the IIS webserver is running or not by writing LOCALHOST in the Browser 2) If not than Go to IIS Manager 3) Open it write click on the IIS server name if not Started → press Start
  • 4. 4) Refresh the “Default Web Site”, you will get your web service folder “TempWebService” from the c:inetpubwwwroot. 5) Now Right Click on “TempWebService” and click on “Convert to Application”
  • 5. 6) After that, to publish the web service, Go to the IIS → “Directory Browsing” and make it ENABLED. 7) Now in right hand panel, you will find Browse-80, Click on it and test the web service in browser. Keep the URI copy for next step of ClientApp development. STEP:3 Create a Client App, Add Web Reference and Use it in the Client App to call Web Service Create Website with Default.aspx at C:inetpubwwwrootmyCalculator <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> <style type="text/css"> .style1
  • 6. { font-size: medium; } </style> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Welcome to ASP.NET! </h2> <p> <asp:Label ID="Label1" runat="server" style="font-size: medium">First No.</asp:Label> <asp:TextBox ID="t1" runat="server" CssClass="style1"></asp:TextBox> </p> <p> <asp:Label ID="Label2" runat="server" style="font-size: medium" Text="Second No."></asp:Label> <asp:TextBox ID="t2" runat="server" CssClass="style1"></asp:TextBox> </p> <p> <asp:Button ID="btnMulti" runat="server" Text="MULTI" onclick="btnMulti_Click" /> <asp:Label ID="lblResult" runat="server" style="font-size: medium"></asp:Label> </p> </asp:Content>
  • 7. using System; using myCalc; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnMulti_Click(object sender, EventArgs e) { int a, b, c; a = Convert.ToInt32(t1.Text); b = Convert.ToInt32(t2.Text); Calcwebservice obj = new Calcwebservice(); c= obj.multi(a, b); lblResult.Text = c.ToString(); } }