Cloud Computing Practicals Final
Cloud Computing Practicals Final
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
Output:
PRACTICAL NO : 2
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
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.
OUTPUT:
Output:
PRACTICAL NO : 4
Aim :- Develop application to consume Google’s search / Google map RESTful Web service
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>
<%
double lati = 0.0;
double 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>
Step 6: After placing the key Right click on project→clean→build→Run index.jsp file
Output:
PRACTICAL NO : 5
Step 2: Now open terminal in ubuntu and type the following command
• Sudo virt-manager
PRACTICAL NO : 6
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 {
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
1. Open the System where you have downloaded the FOSS- Cloud.
6. Now open the browser of another device and type that IP address in new tab.
10. Computer\HKEY_CLASSES_ROOT\spice\shell\open\command
18. Profile→create→windows→default→X_86_64→en-US
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
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