Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Experiment 4 Aim:: Service Oriented Architecture Lab, 2014-15

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Service Oriented Architecture Lab, 2014-15

Veermata Jijabai Technical Institute, Mumbai Page 1



EXPERIMENT 4

Aim:

To create a composition of services from an existing service

Algorithm:
1. Create a WebService client for two Services
2. Create a global variable to store the result from one service
3. Pass this result to another page
4. Use the second service to perform the operation with the result and the newly input data.

STEPS TO CREATE COMPOSITE SERVICE:

1. Create new project. Add two services, Multiply and Addition by creating web service clients.



2. Add this code to the action.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Service Oriented Architecture Lab, 2014-15


Veermata Jijabai Technical Institute, Mumbai Page 2

<title>JSP Page</title>
</head>
<body>
<h2>Addition Result</h2>
<%-- start web service invocation --%><hr/>
<%!
public int result;
%>
<%
try {
addserv.AddServiceService service = new addserv.AddServiceService();
addserv.AddService port = service.getAddServicePort();
// TODO initialize WS operation arguments here
int num1 = 0;
int num2 = 0;
// TODO process result here
String a1=request.getParameter("fst");
String b1=request.getParameter("snd");
num1=Integer.parseInt(a1);
num2=Integer.parseInt(b1);
result = port.result(num1, num2);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
<%-- end web service invocation --%><hr/>
<form name="" action="action2.jsp" method="post">
Enter 1st No:<input name="third" type="text"/><br/>
<input type="hidden" name="hidden" value=<%=result%>>
<input name="ok" type="submit" value="Multiply" />
</form>
</body>
</html>

3. Add the following to the action2.jsp that will be called and passes the value of result of
addition along with the new Service

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
Service Oriented Architecture Lab, 2014-15


Veermata Jijabai Technical Institute, Mumbai Page 3

<body>
<h2>The result of multiplication is </h2>
<%-- start web service invocation --%><hr/>
<%
try {
multservice.MultServiceService service = new multservice.MultServiceService();
multservice.MultService port = service.getMultServicePort();
// TODO initialize WS operation arguments here
String a1=request.getParameter("third");
String b1=request.getParameter("hidden");
int num1 = Integer.parseInt(a1);
int num2 = Integer.parseInt(b1);
// TODO process result here
int result = port.result(num1, num2);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
<%-- end web service invocation --%><hr/>
</body>
</html>

4. Deploy and Undeploy the service.



Service Oriented Architecture Lab, 2014-15


Veermata Jijabai Technical Institute, Mumbai Page 4





Conclusion:

Thus we have created a composite service out of two services which can be called one after
another.

You might also like