0% found this document useful (0 votes)
156 views68 pages

Cloud Computing and Web Service Practicals

The document is a lab manual for Cloud Computing and Web Services at M.S. College of Science, Arts, and Commerce, affiliated with Mumbai University for the academic year 2024-2025. It includes practical exercises on creating web services using Java and .NET, implementing SOAP and REST services, and utilizing cloud functionalities. Additionally, it covers virtualization installation and configuration, as well as applications for downloading and uploading media using MTOM techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views68 pages

Cloud Computing and Web Service Practicals

The document is a lab manual for Cloud Computing and Web Services at M.S. College of Science, Arts, and Commerce, affiliated with Mumbai University for the academic year 2024-2025. It includes practical exercises on creating web services using Java and .NET, implementing SOAP and REST services, and utilizing cloud functionalities. Additionally, it covers virtualization installation and configuration, as well as applications for downloading and uploading media using MTOM techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Habib Education and Welfare Society’s

M.S. COLLEGE OF SCIENCE, ARTS, COMMERCE, BSC


(IT), BSC (CS), B.COM, BMS. (DEVGHAR)

MUMBAI UNIVERSITY

CLOUD COMPUTING AND WEB


SERVICES

LAB MANUAL

(A.Y. 2024 – 2025)


CERTIFICATE

DEPARTMENT OF COMPUTER SCIENCE

This is to certify that Mr. / Miss.

of B.Sc. (CS) Semester VI, Roll No. has successfully completed the practicals in

the subject of Cloud Computing and Web Services as per the requirement of University of Mumbai in

part fulfillment for the completion of Degree of Bachelor of Science (Computer Science). It is also to

certify that this is the original work of the candidate done during the academic year 2024-2025.

INTERNAL EXAMINER SUBJECT TEACHER

H.O.D
DEPARTMENT OF C.S.

DATE OF SUBMISSION: COLLEGE SEAL

2
INDEX
Sr.No. Practical’s Date Sign
1 Define a simple services like Converting Rs into Dollar and
Call it
from different platform like JAVA and .NET
2 Create a Simple SOAP service to find the Square of a
Number
3 Create a Simple REST Service to demonstrate CRUD
operations with “Student” database
4 Develop application to consume Google’s search / Google’s
Map RESTful Web service.

5 Installation and Configuration of virtualization using KVM.

6 Develop application to download image/video from server


or upload image/video to server using MTOM techniques

7 Implement FOSS-Cloud Functionality VSI (Virtual Server


Infrastructure)
Infrastructure as a Service (IaaS), Storage
8 Implement FOSS-Cloud Functionality - VSI Platform as a
Service (PaaS),
9 Using AWS Flow Framework develop application that
includes a simple workflow.
Workflow calls an activity to print hello world to the
console. It must define the basic usage of AWS Flow
Framework, including defining contracts, implementation of
activities and workflow
coordination logic and worker programs to host them
10 Implementation of OpenStack with user and private network
creation.

3
Practical-1(A)

Define a simple services like Converting Rupees into Dollar and Call it from different platform
like JAVA.

Step1 : To create Web Service through Net Beans

4
Step 2: To create Web Service “ ConvertWebService”

Step 3 : to Add Operation “Convert” to Web Service

5
Here Covert is a method having one parameter as rps

Step 4 : After adding code of Operation to web Service

6
Code of Operation :

@WebMethod(operationName = "Convert")
public Double Convert(@WebParam(name = "rps") double rps)
{
double d;
d=rps/83.5;
return d;
}

Step 5 : Now to deploy the web service and Test


i) Deploy

ii) Test Web service

7
After testing

Successfully Deployed and Tested

Step 6: Now to take user input Create input.html page

8
Now insert the code to create html page :

< html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="get" action="Output.jsp">
<p>"Enter Currency in Ruppes " <input type="text" name="rsptxt"></p>
<p><input type="Submit" value="Convert"></p>
</form>
</body>
</html>

Step 7 :
Now to create web service client, for same right click on project and select new thenselect
web service client you will get the following screen:

9
Step 8: Now finally to create Output.jsp page for output

Step 9: After creating the page code is to be added

10
Code to Output.jsp page

<%
try {
p2.CurrencyConvert_Service service = new p2.CurrencyConvert_Service();
p2.CurrencyConvert port = service.getCurrencyConvertPort();

double rps = Double.parseDouble(request.getParameter("rpstxt"));


java.lang.Double result = port.currConvert(rps);
out.println("Currency in Dollar :"+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>

11
Step 10 : Run the application. The following output will be genereted

Output :

12
13
Practical-1(B)

Define a simple services like Converting Rupees into Dollar and Call it from different platform
like .NET

Step1 : To create Web Service through Visual Studio

14
Now to Create a web Service :

15
After click on Add button, CurrConvertService.asmx.cs file will be automatically opened.
Add the following code into Class CurrConvertService :

public double convert(double rs)


{
double d;
d = rs / 83.4;
return d;
}

Save the changes. And run the project. A window will open in browser and that is the web service

16
Now click on Service Description option. Now a new window will be opened. The link is selected and
copied. We will use this link in NetBeans to consume this service

17
Now NetBeans is opened.
To Create a Web Application with name CurrConvertServiceClient. Next -> Finish

Now a Web Service Client is created.


Right click on CurrConvertServiceClient -> New -> Web Service Client.

18
WSDL URL is selected and pasted the link that is copied from browser on run of Visual Studio.
After that click on Finish button.

Now a JSP page is created. Right click on CurrConvertServiceClient -> New -> JSP

Right clicked between body tag and selected-> Call Web Service Operation

19
Now Input.html file of CurrConvertServiceClient project is created and opened and the contents of body
tag is replaced with following code. And then saved it.

<form action="Output.jsp">
<p>Enter Currency in Ruppes : <input type="text" name="txtrs"></p>
<p><input type="submit" value="Convert"></p>
</form>

20
Now the web application is run.

21
Practical-2

Create a Simple SOAP service to find Square of a Number

Step1 : To create Web Service through Net Beans

Step 2: To create Web Service “ Sqr_FindService”

22
Step 3 : to Add Operation “Sqr_Find” to Web Service

23
Here Sqr_Find is a method having one parameter as n

Step 4 : After adding code of Operation to web Service

Code of Operation :

@WebMethod(operationName = "Sqr_Find")
public Integer Sqr_Find(@WebParam(name = "n") int n)
{
int s;
s=n*n;
return s;
}

24
Step 5 : Now to deploy the web service and Test
iii) Deploy

iv) Test Web Service

After testing

25
Successfully Deployed and Tested

Step 6: Now to take user input Create NumInput.html page

26
Now insert the code to create html page :

<html>
<head>
<title>Number Window</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="Output.jsp">
<p>Enter the Number : <input type="text" name="txtnum"></p>
<p><input type="submit" value="Find_SQR"></p>
</form>
</body>
</html>

Step 7 :
Now to create web service client, for same right click on project and select new thenselect
web service client you will get the following screen:

27
Step 8: Now finally to create Output.jsp page for output

28
Step 9: After creating the page code is to be added

29
Code to Output.jsp page

<%
try {
p1.SqrFindService_Service service = new p1.SqrFindService_Service();
p1.SqrFindService port = service.getSqrFindServicePort();

int n =Integer.parseInt(request.getParameter("txtnum"));
java.lang.Integer result = port.sqrFind(n);
out.println("Square of "+n+" is "+result);
}
catch (Exception ex)
{

}
%>

Step 10 : Run the application. The following output will be generated

30
Output :

31
Practical-3

Create a Simple REST Service to demonstrate CRUD operations with


“Student” database
1. Click on Window menu and click on Projects, Files & Services to open it.

2. Right click on Java DB and then click on Start Server to start the server .

3. Now expand Java DB and right click on sample and then click on connect to connect the
sample database with server.

32
4. Now create a web application with the name CRUD_Operation. A window will open like
following pic.

33
5. Create an entity class. Right click on project name -> New -> Entity Class.

6. A window will appear like bellow pic. Enter following data and click on Next ….
Class Name ->Stud_Name Package Name -> p1
7. Click on finish.

34
8. Right click on project name and create JSF Pages from Entity Classes.
9. Select and click on Add button and then Next button on below

35
10. A window like below will appear on the screen. Enter the data into that window as entered in
below pic and click on Next button.

36
11. Now click on Finish.

12. Right click on project name and create RESTful Web Services from Entity Classes.

37
13. Repeat step 9 and then it will go on next page. Then enter the p1.service in Resource Package
and then click on Finish button.

38
14. Now open Stud_Name.java file under p1 package.
15. In this file at line number 24, do the right click and select Insert Code.
16. A new list will appear. Click on Add Property

17. A new window will open. Enter name as studName. Make sure name should be exact same as of
mine and then click on OK button. Actually we are setting getter and setter method for studName.

39
18. Now right click on web application name and Deploy it.

19. Now right click on project name and run it

20. A window will open in browser like below….

40
41
Practical-4

Develop application to consume Google’s search / Google’s Map RESTful Web


service.

1. First of all we need to create an Java Web Application with any name, let it be GoogleMap here using
Netbeans IDE.

2. Create a Input.jsp page to get Latitude and Longitude

42
3. The following code is inserted in that Input.jsp page

<form action="index.jsp">
<pre>
Enter latitude:<input type="text"
name="t1" /> Enter longitude:<input
type="text" name="t2" />
<input type="submit" value="Show" />
</pre>
</form>

4. Before running the application we need the Google API key. The steps are shown here: - Visit Google
APIs Console (https://console.developers.google.com, you have to login with your Google account).

43
5. Enable the Google Maps API V3

6. To Create Index.jsp page

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<html>
<head>
<style>
#map {
height: 400px;
width: 100%; }
</style>
</head>
<body>
<%
double lati=Double.parseDouble(request.getParameter("t1"));
double longi=Double.parseDouble(request.getParameter("t2"));
%>
<h3> Google Maps </h3>
<div id="map"></div>
<script lang="javascript">
function initMap()
{
var info={lat: <%=lati%>, lng: <%=longi%>};
var map = new google.maps.Map(document.getElementById('map'),
{
zoom: 4, center: info
});
var marker = new google.maps.Marker({ position: info,
map: map
});
}
</script>

44

44
<script async defer
src="put your key here">

</script>
</body>
</html>

Index. Jsp

To run application :

45
Output :

46
Practical-5

Installation and Configuration of virtualization using KVM

Installation Steps :

First we need to open VMware WorkStation

For the installation following commands are to be executed:

Step 1 : #sudo grep -c "svm\|vmx" /proc/cpuinfo

47
Step 2 : #sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager

Step 3 : #sudo adduser rait

Step 4 : #sudo adduser rait libvirt


After running this command, log out and log back in as rait

48
Step 5 : Open Virtual Machine Manager application and Create Virtual Machine
#virt-manager as shown below

Step 6 : Create a new virtual machine as shown below

49
Step 7 : Install windows operating system on virtual machine

Step 8: Installation of windows on virtual machine

50
Step 9: Installation of windows 7 on virtual machine

Step 10: Initialization of windows on virtual machine

51
Practical-6

Develop application to download image/video from server or upload image/video to


server using MTOM techniques

MTOMClient Index.jsp
<%@page import="java.io.BufferedOutputStream">
<%@page import="java.io.FileOutputStream">
<%@page import="java.io.FileInputStream">
<%@page import="java.io.BufferedInputStream">
<%@page import="javax.imageio.stream.FileImageInputStream">
<%@page import="java.io.File">
<%@page import="javax.xml.ws.soap.MTOMFeature">
<%@page contentType="text/html" pageEncoding="UTF-8">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<%-- start web service invocation --><hr/>


<%
try {
pkg.ImageWS_Service service = new
pkg.ImageWS_Service(); pkg.ImageWS port =
service.getImageWSPort(new
MTOMFeature(60000));
// TODO initialize WS
operation arguments here
String
filePath="c:/msc/ABC.jpg";
File file=new File(filePath);
FileInputStream fis=new
FileInputStream(file);
BufferedInputStream bis=new
BufferedInputStream(fis);
java.lang.String filename =
file.getName();
byte[]imageBytes=new
byte[(int)file.length()];
bis.read(imageBytes);
port.upload(filen
ame,
imageBytes);
bis.close();
out.println("File uploaded :"+filePath);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
>
<%-- end web service invocation --><hr/>

52
<%-- start web service invocation --><hr/>
<%
try {

pkg.ImageWS_Service service = new


pkg.ImageWS_Service(); pkg.ImageWS port =
service.getImageWSPort();
// TODO initialize WS operation
arguments here java.lang.String
filename = "ABC.jpg";
String filePath="c:/msc/download/"+filename;
// TODO process result here
byte[] fileBytes =
port.download(filename);
FileOutputStream fos=new
FileOutputStream(filePath);
BufferedOutputStream bos=new
BufferedOutputStream(fos);
bos.write(fileBytes);
bos.close();
out.println("File downloaded"+filePath);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
>
<%-- end web service invocation --><hr/>
</body>
</html>

MTOMServer
ImageWS.java
package mypkg;
import java.io.*;
import javax.jws.Oneway;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.xml.ws.soap.MTOM;
@MTOM(enabled=true,threshold=60000)
@WebService(serviceName = "ImageWS") public class ImageWS { @WebMethod(operationName = "upload")
@Oneway
public void upload(@WebParam(name = "Filename") String Filename, @WebParam(name = "ImageBytes") byte[]
ImageBytes){
String filePath="C:/MSC/upload/"+Filename; try
{
FileOutputStream fos=new FileOutputStream(filePath); BufferedOutputStream bos=new BufferedOutputStream(fos);
bos.write(ImageBytes);
bos.close();
System.out.println("Recieved file :"+filePath);
}
catch(Exception ex)

{
System.out.println(ex);

53
}
}
@WebMethod(operationName = "download")
public byte[] download(@WebParam(name = "Filename")
String Filename) { String
filePath="C:/MSC/upload/"+Filename;
System.out.println("Sendi
ng file :"+filePath); try
{
File file=new File(filePath);
FileInputStream fis=new
FileInputStream(file);
BufferedInputStream bis=new
BufferedInputStream(fis); byte[]
fileBytes=new byte[(int)file.length()];
bis.read(fileBytes);
bis.close(); return fileBytes;
}
catch(Exception ex)
{
System.out.println(ex);
}
return null;
}
}

54
Practical-7

Implement FOSS-Cloud Functionality VSI (Virtual Server Infrastructure)


Infrastructure as a Service (IaaS), Creating Virtual Machine or Storage

Steps:
1. Open terminal and enter the following Command ‘’sudo apt upgrade” and “sudo apt update”

2. Enter the following command to install virt manager

3. Launch Virt Manager using Following Command:


$ Sudo virt-manager

4. Once the virt manager is launched click on file➔ new virtual machine

55
Select local install media (ISO image or CDROM) and click Forward

Click on Browse➔ Browse local ➔ select downloaded iso file ➔ Open

56
Uncheck The checkbox and Choose the OS you are installing as “Generic default” and click“Forward”

5. Provide the Memory, CPU,Storage,Name For Virtual Machine and click “Forward”
6. Once the foss Cloud is launched select “Foss-Cloud installer :default boot options” and press Enter

Types yes to start the installation

7. Select “Demo System” and press Enter


Enter the Device name as “sda” and press enter
Practical-9

Using AWS Flow Framework develop application that includes a simple


workflow. Workflow calls an activity to print hello world to the console. It must
define the basic usage of AWS Flow Framework, including defining contracts,
implementation of activities and workflow coordination logic and worker
programs to host them

Step 1: Open Terminal and Update and Upgrade your system by command

sudo apt-get update && sudo apt-get upgrade

Step 2: Download awscliv2.zip with command


curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

Step 3: Download awscliv2.sig file with command


curl -o awscliv2.sig https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig
Step 4: unzip awscliv2.zip with command
unzip awscliv2.zip

Step 5: Run command


sudo ./aws/install

Step 6: Type command


pip3 install aws-sam-cli
Step 7: Type command sam init in terminal to launch Sam

CLISelect 1st option to use AWS Quick Ttart Templates

Step 8: Select Template no.1 Hello World Example

Step 9: Type “N” if it ask to use most popular runtime and package type

Open new terminal by pressing ctrl+shift+T and check for python version by command
python –version

Select the option according to your python version in my case its option 19- python 3.11
Step 10: Select package type as Zip

Step 11: Now choose Yes option everytime it ask .

Give project name as per your preference in my case its sam-app-test


Step 12: Now one folder will be created by your provided project name go into that folder by
command cd (folder name)

After entering the project folder we will invoke the HelloWorldFunction by using commandsam
local invoke „HelloWorldFunction‟

It should give you StatusCode:200

Use command sudo snap install docker if docker error occurs.

Step 13: Type command sam local start-api this will give you URL open it in any browser.

Output:
Practical-10

Implementation of OpenStack with user and private network creation.

Implementation of Openstack with user and private network creation. Minimum


Requirements

Before we begin, ensure you have the following minimum prerequisites

1. A fresh Ubuntu 18.04 installation


2. User with sudo privileges
3. 4 GB RAM
4. 2 vCPUs
5. Hard disk capacity of 10 GB
6. Internet connection

With the minimum requirements satisfied, we can now proceed.

Steps:
Step 1: Update and Upgrade the System
To start off, log into your Ubuntu 18.04 system using SSH protocol and update &
upgra system repositories using the following command.

apt update -y && apt upgrade -y

Sample Output

Next reboot the system using the command.


sudo reboot
Step 2: Create Stack user and assign sudo priviledge
Best practice demands that devstack should be run as a regular user with sudo privileg
With that in mind, we are going to add a new user called “stack” and assign sudo privi
To create stack user execute
sudo adduser -s /bin/bash -d /opt/stack -m stack
Next, run the command below to assign sudo privileges to the user Sample Output

echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack


Step 3: Install git and download DevStack

Once you have successfully created the user ‘stack’ and assigned sudo privileges, swit the user

using the command.

su - stack

In most Ubuntu 18.04 systems, git comes already installed. If by any chance git is miss install it by
running the following command.

sudo apt install git -y

Sample output

Using git, clone devstack’s git repository as shown. Sample


git clone https://git.openstack.org/openstack-dev/devstack
output

Step 4: Create devstack configuration file


In this step, navigate to the devstack directory. Then create

acdlocal.conf
devstackconfiguration file.

vim local.conf
Paste the following content

[[local|localrc]]

# Password for KeyStone, Database, RabbitMQ and Service


ADMIN_PASSWORD=StrongAdminSecret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD

# Host IP - get your Server/VM IP address from ip addr command


HOST_IP=10.208.0.10

Save and exit the text editor. NOTE:


1. The ADMIN_PASSWORD is the password that you will use to log in to the
OpenStack login page. The default username is admin.
2. The HOST_IP is your system’s IP address that is obtained by running ifconfig or ip addr
commands.
Step 5: Install OpenStack with Devstack

To commence the installation of OpenStack on Ubuntu 18.04, run the script below cont in

devstack directory.

./stack.sh

The following features will be installed:

● Horizon – OpenStack Dashboard


● Nova – Compute Service
● Glance – Image Service
● Neutron – Network Service
● Keystone – Identity Service
● Cinder – Block Storage Service
● Placement – Placement API

The deployment takes about 10 to 15 minutes depending on the speed of your system internet
connection. In our case, it took roughly 12 minutes. At the very end, you shoul output similar to
what we have below.
This confirms that all went well and that we can proceed to access OpenStack via a we browser.

Step 6: Accessing OpenStack on a web browser


To access OpenStack via a web browser browse your Ubuntu’s IP address as shown.
https://server-ip/dashboard This directs you to a login page as shown.

Enter the credentials and hit “Sign In” You should be able to see the Management console
dashboard as shown below.

You might also like