0% found this document useful (0 votes)
34 views

Webservices Arithmetic

This document describes how to create a web application that performs arithmetic operations using web services. The application is created in Visual Studio by adding an empty web form and a web service. The web service contains methods for addition, subtraction, multiplication, and division that take integer parameters. The web form calls these methods and displays the results. Users can enter two numbers, select an operation, and see the output displayed on the form. The document provides code samples for the web service and web form to implement this functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Webservices Arithmetic

This document describes how to create a web application that performs arithmetic operations using web services. The application is created in Visual Studio by adding an empty web form and a web service. The web service contains methods for addition, subtraction, multiplication, and division that take integer parameters. The web form calls these methods and displays the results. Users can enter two numbers, select an operation, and see the output displayed on the form. The document provides code samples for the web service and web form to implement this functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Web Programs using Web Services

Aim

To perform arithmetic operations using web services.

Procedure

Choose start->All Programs->Microsoft Visual Studio 2010 ->Microsoft Visual Studio


2010.

Choose File--> New website and then select ASP.Net Empty Website.

Specify the web location to save and then click ok button.

In solution explorer window, right click on the path of web location and select Add New
Item and then select webform. Also change the name of the webform (.aspx). Then click add
button.

Select design tab in the bottom side of the form.

Choose Table - > Insert Table to add a new table. Then specify the rows as 6 and
columns as 2.

Add the required label box, text box and button in the form.

A web service is a web-based functionality accessed using the protocols of the web to be
used by the web applications.

In solution explorer window, right click on the path of web location and select Add New
Item and then select webservices Also change the name of the web service(arithmetic.aspx).
Then click add button.

Type the required code in webservice and webform.

Press F5 to run an application

Coding

Webservices coding
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class Arithmetic


Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function add(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
Public Function subtract(ByVal a As Integer, ByVal b As Integer) As Integer
Return a - b
End Function
Public Function multiply(ByVal a As Integer, ByVal b As Integer) As Integer
Return a * b
End Function
Public Function divide(ByVal a As Integer, ByVal b As Integer) As Integer
Return a / b
End Function

End Class

Webform coding
Imports Arithmetic

Partial Class _Default


Inherits System.Web.UI.Page

Private obj As Arithmetic = New Arithmetic()


Private a, b, c As Integer

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
a = Convert.ToInt32(TextBox1.Text)
b = Convert.ToInt32(TextBox2.Text)
c = obj.Add(a, b)
TextBox3.Text = c.ToString()

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button2.Click
a = Convert.ToInt32(TextBox1.Text)
b = Convert.ToInt32(TextBox2.Text)
c = obj.subtract(a, b)
TextBox3.Text = c.ToString()
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button3.Click
a = Convert.ToInt32(TextBox1.Text)
b = Convert.ToInt32(TextBox2.Text)
c = obj.multiply(a, b)
TextBox3.Text = c.ToString()
End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button4.Click
a = Convert.ToInt32(TextBox1.Text)
b = Convert.ToInt32(TextBox2.Text)
c = obj.divide(a, b)
TextBox3.Text = c.ToString()
End Sub
End Class

Output

Result

Thus an arithmetic operations were performed successfully using webservices.

You might also like