Web Service pr6
Web Service pr6
6:
~Made by Shlok Punekar
namespace Webservice
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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 WebService1 : System.Web.Services.WebService
{
[WebMethod]
public double add(double a, double b)
{
return a + b;
}
[WebMethod]
public double subtract(double a, double b)
{
return a - b;
}
[WebMethod]
public double multiply(double a, double b)
{
return a * b;
}
[WebMethod]
public double divide(double a, double b)
{
return a / b;
}
}
}
Output:
Click on Service Description url
Select WSDL URL and paste the copied url of XML file in it, give package name and finish
Web Service Client added
Create a new jsp file
Source Code:
Index.html:
<!DOCTYPE html>
<!--
-->
<html>
<head>
</head>
<body>
</form>
</body>
</html>
Operations.jsp:
<%--
Document : Operations
Author : student
--%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%-- start web service invocation --%><hr/>
<%
double a = Integer.parseInt(request.getParameter("n1"));
double b = Integer.parseInt(request.getParameter("n2"));
try {
out.println("Result = "+result);
%>
<%
try {
out.println("Result = "+result);
}
%>
<%
try {
out.println("Result = "+result);
%>
<%
try {
out.println("Result = "+result);
%>
<%-- end web service invocation --%><hr/>
</body>
</html>
Output: