0% found this document useful (0 votes)
138 views48 pages

Cloud Computing Practicals Final

The document outlines a series of practical exercises focused on cloud computing and web services, including creating web services in Java and .NET, developing RESTful services, consuming Google Maps API, and implementing virtualization using KVM. Each practical includes step-by-step instructions for setting up projects, coding, and testing various web services and applications. Additionally, it covers the installation and configuration of FOSS-Cloud for Infrastructure as a Service (IaaS) and Platform as a Service (PaaS).

Uploaded by

Ahlam Khan
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)
138 views48 pages

Cloud Computing Practicals Final

The document outlines a series of practical exercises focused on cloud computing and web services, including creating web services in Java and .NET, developing RESTful services, consuming Google Maps API, and implementing virtualization using KVM. Each practical includes step-by-step instructions for setting up projects, coding, and testing various web services and applications. Additionally, it covers the installation and configuration of FOSS-Cloud for Infrastructure as a Service (IaaS) and Platform as a Service (PaaS).

Uploaded by

Ahlam Khan
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/ 48

PRACTICAL NO : 1

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Define a simple service like converting Rs into Dollar and call it from different
platform like JAVA and .NET.

Step 1 : Create java web application project -> Right click on web service and create web
series -> create package

Step 2 : Right click on web server page -> Insert code -> select add web service operation
Currency.java file :

Step 3: Right click on web service name -> Test web service

Step 4: Right click web page -> create 2 jsp web pages ( input and output)

Input.jsp file:
Step 5: Right click on project -> create web service client -> browse current project web
service file (currency) -> create new package name

Step 6: Drag and drop InrtoDollar operation into output.jsp file from

Web service references


Output.jsp

Step 7: Deploy project -> Run input.jsp file

Output:
PRACTICAL NO : 2

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Create a simple SOAP Service.

Step 1 : Create the new project in netbeans software

Step 2 : File→New Project→Java web→web Application→Next

Step 3: Now right click on your project and Add→New→Web Service. -> Give the web
service name and package Name.

Step 4: Now open Web services folder→ Right click on your web webservice→Add operation
Web service file

CODE :

/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
*
* @author User
*/
@WebService(serviceName = "Operations")
public class Operations {

/**
* This is a sample web service operation
*/
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}

/**
* Web service operation
*/
@WebMethod(operationName = "Addition")
public int Addition(@WebParam(name = "n1") int n1,
@WebParam(name = "n2") int n2) {
int sum = n1 + n2;
return sum;
} // <-- Missing closing brace fixed here

/**
* Web service operation
*/
@WebMethod(operationName = "Subtraction")
public int Subtraction(@WebParam(name = "n1") int n1,
@WebParam(name = "n2") int n2) {
int sub = n1 - n2;
return sub;
}

/**
* Web service operation
*/
@WebMethod(operationName = "Multiplication")
public int Multiplication(@WebParam(name = "n1") int n1,
@WebParam(name = "n2") int n2) {
int mul = n1 * n2;
return mul;
}

/**
* Web service operation
*/
@WebMethod(operationName = "Division")
public int Division(@WebParam(name = "n1") int n1,
@WebParam(name = "n2") int n2) {
if (n2 == 0) {
throw new ArithmeticException("Division by zero is not
allowed.");
}
int div = n1 / n2;
return div;
}
}
Step 5: Right click on project→Deploy
Step 6: Write click on webservice→Test Web Service

Output:
PRACTICAL NO : 3

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Create a simple REST service

Step 1: Create a java web application.

Step 2: Right click on project→new→others→web services →RESTful web services from


patterns. -> Simple root resource

Step 3: Change the code and create methods as following…

Generic resource file Code:

package server;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;
import javax.ws.rs.core.MediaType;

/**
* REST Web Service
*
* @author User
*/
@Path("generic")
public class GenericResource {

@Context
private UriInfo context;
/**
* Creates a new instance of GenericResource
*/
public GenericResource() {
}

/**
* Retrieves representation of an instance of
server.GenericResource
* @return an instance of java.lang.String
*/
@GET
@Produces(MediaType.APPLICATION_XML)
public String getXml() {
//TODO return proper representation object
throw new UnsupportedOperationException();
}

/**
* PUT method for updating or creating an instance of
GenericResource
* @param content representation for the resource
*/
@PUT
@Consumes(MediaType.APPLICATION_XML)
public void putXml(String content) {
}

/**
* PUT method for handling HTML content
*/
@PUT
@Consumes(MediaType.TEXT_HTML)
public void putHtml(String content) {
}

/**
* PUT method to convert string to uppercase
*/
@PUT
@Consumes(MediaType.TEXT_HTML)
@Path("/Uppercase")
public String toUppercaseMethod(String str) {
return str.toUpperCase();
}

/**
* PUT method to convert string to lowercase
*/
@PUT
@Consumes(MediaType.TEXT_HTML)
@Path("/Lowercase")
public String toLowercaseMethod(String str) {
return str.toLowerCase();
}
}

Step 4: Right click on project and clean the project and after deploy it.

Step 5: Right click on RESTful web services→Test Restful web service→ok

OUTPUT:

Output:
PRACTICAL NO : 4

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Develop application to consume Google’s search / Google map RESTful Web service

Step 1: Create a java web application.

Index.html file :

<!DOCTYPE html>
<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 action="index.jsp">
<pre>
ENter Latitude : <input type="text"
name="n1"><br><br>
ENter Longitude : <input type="text"
name="n1"><br><br>
<input type="submit" value="shoe"/>
</pre>
</form>
</body>
</html>

Step 2: Right click on project -> Create jsp file


Index.jsp file :

<%@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>
<style>
#map {
height: 400px;
width: 100%; /* Changed width to 100% for better
map display */
}
</style>
</head>
<body>
<form action="index.jsp">
<pre>
Enter Latitude : <input type="text"
name="n1"><br><br>
Enter Longitude : <input type="text"
name="n2"><br><br>
<input type="submit" value="Show Map"/>
</pre>
</form>

<%
double lati = 0.0;
double longi = 0.0;

if (request.getParameter("n1") != null &&


request.getParameter("n2") != null) {
try {
lati =
Double.parseDouble(request.getParameter("n1"));
longi =
Double.parseDouble(request.getParameter("n2"));
} catch (NumberFormatException e) {
lati = 0.0; // Default value if the input is
not a valid number
longi = 0.0;
}
}
%>

<h3>Google Map</h3>
<div id="map"></div>

<script>
function initMap() {
var info = { lat: <%= lati %>, lng: <%= longi %>
}; // Corrected 'ing' to 'lng'
var map = new
google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: info
});
var marker = new google.maps.Marker({
position: info, // Fixed syntax for position
map: map
});
}
</script>

<!-- Google Maps API with callback to initMap -->


<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA1J_QLgeH3vUD
7x36W-iKO2KHPYdlUYDo&callback=initMap" async defer></script>
</body>
</html>

Step 3: Open console.cloud.google.com in chrome


Step 4: API’s and services →library→Map JavaScript API and place API →Enable -> API’s and
services →Credentials
Step 5: Now select Restrict key and select dropdown and select both checkboxes.

Step 6: After placing the key Right click on project→clean→build→Run index.jsp file

Output:
PRACTICAL NO : 5

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Installation and configuration of virtualization using a KVM

Step 1: Open the VMWere. -> open Ubuntu terminal

Step 2: Now open terminal in ubuntu and type the following command

• sudo apt-get update


.cat /proc/cpuinfo

• sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-


clients bridge-utils virt- manager

• Sudo virt-manager
PRACTICAL NO : 6

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Develop application to download image/video from server or upload image/video


to server using MTOM techniques

1. Open Visual Code and create a new project.


2. Select ASP.NET Application(.NET Framework)
3. Give your project a name
4. After that open solution explorer→Right click on project→Add→New Item→Web
Service(ASMX) and give it a name→Add
DownloadImg.asmx.csusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace DownloadImgFromWS
{
/// <summary>
/// Summary description for DownloadImgWS
/// </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 DownloadImgFromWS : System.Web.Services.WebService
{
[WebMethod, Description("Get Image Content")]
public byte[] GetImgFile(string fileName)
{
if (System.IO.File.Exists(Server.MapPath("~/Images/") + fileName))
{
return System.IO.File.ReadAllBytes(Server.MapPath("~/Images/") + fileName);
}
else
{
return new byte[] { 0 };
}
}

}
}
5. Now again right click on project→Add→new item→search handler→select generic
handler and give name
MyHandler.ashx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DownloadImgFromWS
{
/// <summary>
/// Summary description for MyHandler
/// </summary>
public class MyHandler : IHttpHandler {

public void ProcessRequest (HttpContext context)


{
DownloadImgFromWS ws = new DownloadImgFromWS();
byte[] binImage = ws.GetImgFile(context.Request["fileName"]);
if(binImage.Length == 1)
{
//do nothing
}
else
{
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(binImage);
}
}

public bool IsReusable {


get {
return false;
}
}
}
}
6. Again right click on project→Add→new item→select web form→Give it a name

7. Click on View→toolbox→design the following form


8. Now double click on the button and change the code

9. Right click on Project and create folder images and paste the images.
10. After that execute the code and Enter the Image name in Text field.

Output:
PRACTICAL NO : 7

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Implement FOSS-Cloud Functionality VSI (Virtual Server Infrastructure) frastructure


as a Service (IaaS), Storage

1. Open the System where you have downloaded the FOSS- Cloud.

2. Enter user-root & Password-admin.


3. Now Right following command • fc-node- configuration -n demo- system –password
admin

4. Now enter ifconfig command.

5. Now copy or save the IP Address (192.168.0.192)

6. Now open the browser of another device and type that IP address in new tab.

7. Username-admin & Password-admin


8. Now download Virtviewer software and Spice client software

9. Now open Registry editor

10. Computer\HKEY_CLASSES_ROOT\spice\shell\open\command

11. We have to edit the command.

12. Open the path of Remote viewer.

13. C:\Users\ A(find in hidden files and folders) \AppData\Local\virt-viewer\bin


14. Now open Registry editor and→Right click on it→Modify→Paste the path and add
\remote-viewer %1 at the end.

15. Come back to browser→virtual Machine→Upload ISO file→choose file

16. Select the Ubuntu ISO file.


17. After successful upload you will get message Upload finished.

18. Profile→create→windows→default→X_86_64→en-US

19. Now do following setup and click on create button.


20. Virtual Machine→VM tamplete→create
21. Now click on Right arrow button under Run action.

22. Now you can see status is running.

23. Click on VM template bar button in Action

24. You will get alert box Click on open-remote viewer.


OUTPUT:
1. Open terminal and Type the following commands.

2. Before starting the installation you have to update or upgrade the system • Sudo apt-get
update

3. Create new user and give permissions to start the OpenStack. • Sudo adduser stack •
Sudo -i • Echo “stack ALL=(ALL) NOPASSWD:ALL”>>/etc/sudoers.

4. Download the Devstack from Github.com • Sudo apt-get install git • Git clone https://git
.openstack.org/openstack-dev/dev/devstack

5. Run the following commands to avoid the Errors before installation • Sudo rm
/var/lib/dpkg/lock • Sudo rm /var/lib/apt/lists/lock • Sudo rm /var/cache/apt/archives/lock
• Sudo rm -rf/var/lib/apt/lists/*

6. Configure local.conf file • cd devstack/ • cd samples • cp local.conf ../ • cd.. • sudo nano
local.conf • ADMIN_PASSWORD=pass1 • DATABASE_ PASSWORD=pass1 •
RABBIT_PASSWORD=pass1 • SERVICE_ PASSWORD=pass1 • HOST_IP=10.0.2.15(your ip
address) • FLOATING_RANGE=10.0.2.224/24 • ctrl+x ->y

7. Now you can start your installation process. • ./stack.sh


PRACTICAL NO : 8

Name: Class:TYCS Date:

Subject: CLOUD COMPUTING AND WEB SERVICES Roll no:

Aim :- Implement FOSS-Cloud Functionality - VSI Platform as a Service (PaaS)

Software development Kits can be made available in the Virtual Machines that can be
implemented as Platform as a Service.

Installation of Netbeans, Eclipse, Visual Studio and DBMS can be done in the appropriate
Virtual Machines

You might also like