0% found this document useful (0 votes)
31 views273 pages

CC Final Practs - Merged

This document is a certificate from K.M. Agrawal College of Arts, Commerce and Science, certifying the completion of a journal for the Bachelor of Computer Science course. It includes an index of practical assignments related to Cloud Computing and Web Services, detailing various tasks such as creating SOAP and RESTful web services, and developing applications using different programming languages. Additionally, the document outlines steps for practical implementations and client development for web services.

Uploaded by

Dhruv Borse
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)
31 views273 pages

CC Final Practs - Merged

This document is a certificate from K.M. Agrawal College of Arts, Commerce and Science, certifying the completion of a journal for the Bachelor of Computer Science course. It includes an index of practical assignments related to Cloud Computing and Web Services, detailing various tasks such as creating SOAP and RESTful web services, and developing applications using different programming languages. Additionally, the document outlines steps for practical implementations and client development for web services.

Uploaded by

Dhruv Borse
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/ 273

K.M.

AGRAWAL COLLEGE OF ARTS, COMMERCE


AND SCIENCE

KALYAN

NAAC ACCREDITED B++

CERTIFICATE
This is to certify that Mr./Ms.____________________________________________Exam Seat
No__________________ has satisfactorily completed the Journal on
_________________________________________________for partial fulfillment of the 3
year Full Time Course Bachelor of Computer Science (SEM-VI) of the University of Mumbai
forthe year 2023-2024.

Exam Seat No:___________ Roll No.: ___________

Place : KALYAN Date : / /

Prof. In-Charge In-Charge External Examiner Signature


Self-Finance Department
INDEX

Sr.No Date Practical List Sign.


1. 10/01/24 Create a Simple SOAP service

2. 24/01/24 Create restfull web service

3. A] 3/01/24 A] Create a Simple REST Service

3. B] 3/01/24 B] Develop Micro-blogger application (like Twitter) using


RESTful Web services.

4. 07/02/24 Develop application to consume Google’s search /


Google’s Map RESTful Webservice.

5. 21/02/24 Installation and Configuration of virtualization using KVM

6. 28/02/24 Develop application to download image/video from server or


upload image/videoto server using MTOM techniques

7. 13/03/24 Develop client which consumes web services developed in


different platform. Create a webservice in netbean and use it
in .NET

8. 20/03/24 Implement FOSS-Cloud Functionality VSI (Virtual Server


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

9. 27/03/24 Implement FOSS-Cloud Functionality - VSI Platform as a


Service (PaaS)

10. 03/04/24 Write a program to implement to create a simple web service


that converts the temperature from Fahrenheit to Celsius and
vice a versa.
TYCS SEM-VI Cloud Computing and Web Services Journal

Practical-1
Create a Simple SOAP service.

Steps:
1] Open the NetBeans , and you will get the following screen. Close the start page.

2] Now click on the file tab and click on new project you will get the following screen :
TYCS SEM-VI Cloud Computing and Web Services Journal

3] In Categories select Java Web and in Projects , Select Web Application .After selecting click onnext .
You will get the following window:

4] Now Give name to the Project Name: , and click on next . you will get the following windowthen
. again click on finish:
TYCS SEM-VI Cloud Computing and Web Services Journal

5] You will get the following screen now carefully see in projects section your recently created project
appears double click to expand it:

6] Now Right click on the project and select new and then select Web Service ,As shown Below:
TYCS SEM-VI Cloud Computing and Web Services Journal

7] after clicking Web Service following window should appear , now give name to web serviceand
give package as “server”. As shown in the image:

After clicking finish you should get the following window erase the mentioned code :

8] Now right click any where and click on insert code and select Add Web Service Operation :
9] the following window would appear :
Just give name to the method or operation and click on add button to add parameters to the method as
here we are converting dollar to rupees we should need only one parameter .

10] give the name to the variable select data type as double and click on ok as shown below:
11] After clicking ok code will autogenerate , make changes In that code as mentioned below:

12] now our web service is ready now right click on project and click on deploy :

13] now right click on webservice and click on test web service you will get the following output:
https://study.cscornersunitarai.com/ https://www.youtube.com/@cscornersunitarai

TYCS SEM-VI Cloud Computing and Webservices Journal

So this is how we created our web service and deployed it.


TYCS SEM-VI Cloud Computing and Webservices Journal

Creating a java Client using jsp

14] now our web service is successfully deployed. Right click on web pages and select new and
select jsp as shown below:

15] give name and click on finish as shown below do it 2 times on for input and one foroutput:

16] In input.jsp create a form for taking user input as shown below:
In this code set action = the jsp file where u want output and give name to textbox input.

17] now we have to create web service client, for same right click on project and select new then
select web service client you will get the following screen:

At this step click on browse and select your project and click ok after clicking ok you will get wsdl url as
shown below:
At this stage copy the url and paste it in notepad for future.
Give package name as “Client”.

Now click on finish.

18] now in project section you can se a new folder is been created named “web servicerefrence”.
double click to expand it you should get the following :
Hold the operation or your operation name and drag it into the output.jsp in body tag as shown
: You will get the following auto generated code:

19] now make changes as shown below in the code:

20] now Deploy our project again and right click on input.jsp and click run file you will redirect to a
browser page as shown :
Enter any numerical value in text box and click on submit you will get the following output:
Python client:

1] for consuming java web services in python we should repeat the above steps till step np.19 .

Note: for getting output the project or web service should be deployed .

After doing all of the steps write the following code in python idle:

Code :

from zeep import Client


wsdl_url='http://localhost:8080/pract/Currency?wsdl'
client=Client(wsdl_url)

#call the method on the webservice


d=float(input("Enter Currency in Indian Rupees:"))
result = client.service.InrtoDollar(d)
print(result)2] replace wsdl_url with the url which was copied at the time of web service client
creation .

In step no.17 . and replace the InrtoDollarwith your method or operation name. and pass parameter
to it

3] final code should look like following:

4] after running the above code you should get the following output:
.Net Client

1] open visual studio and select create a new project the following window will appear:

Here in search bar type “console c#” and select console app for .Net frame work as shown in
above image.

2] Give name to the project and press create button as shown in the image:
This window should appear after clicking create button now In right side there is solution Explorer.

In that right click on your project name and click on add > Service Reference . You will get the
following window :

Note: before executing the code make sure that the web service is deployed.

Here in address bar paste the wsdl url the same which is used I python code. And press go button . agter
set the namespace In my case I am letting is as it is then press ok button.
In following image u can check in solution Explorer service refrence iscreated.:
3] now in code write the following line as shown in image:

Here type:
Using your_projectname . your_serviceReference_name ;

4] now write the code as shown in the following image:


Note:

Here CurrencyClient is my webservice class name and operation() is my method name as show
you can also check your own:

5] when you run the above code you get the following output:
Practical-2

Create restfull web service


Open Mysql command lie client
Type the following code

Create database mydbs2;


Use mydbs2;
CREATE TABLE emp1( eid INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20),dept VARCHAR(55));

Open netbeans
Take new project-----java web(left)----new application(right)
Practical-3A

Create a Simple REST Service

 Demonstrate CRUD operations with suitable database using RESTful Web service.

1. To start the Java DB Database from NetBeans, perform the following steps.

Click Services tab -> Expand Databases node. ->Right-click Java DB icon.

->Select Start Server

2. To create playerDB database, perform the following steps:

a. Right-click Java DB icon, select Create Database.


b. Enter the following information for the database:

Database Name:
playerDBUser Name:
john Password: john
Confirm Password:john

c. Click OK.

3. To connect to the newly created database playerDB, perform the following steps

a. Right-click jdbc:derby://localhost:1527/playerDB connection.

b. Select Connect.

4. Create tables and populate them with data in playerDB database.

a. In NetBeans select File > Open File.

b.In the file select playersDB.sql.

c. Click Open. The script automatically opens in the SQL Editor.

5. Examine the contents of the database.

a. In the Services window, expand the jdbc:derby://localhost:1527/playerDB connection


underthe Databases node.
b. Right-click the connection and select Refresh.
c. Expand the john schema. You see the nodes for Tables, Views, and Procedures. d.
Expand the Tables node to see the PLAYER and TEAM tables. e. Right-click the
PLAYER table node and select View Data.

Player server
To create RESTful Web Services, you need a Java Web application project. In the below section you
willcreate a demo Java web project, PlayerServer.
To create new Java Web Project, select File -> New Project -> Java web -> Web Application.
Generating web service
To generate RESTful Web Services do the following:
1.Right-click the PlayerServer and choose New > Other > Web Services > RESTful Web Services from
Database. The New RESTful Web Service wizard opens on the Database Tables panel.
2. In the Database Tables window, select Data Source.

3. Next select "New Data Source" from the Drop-down list.


a. In the Create Data Source Window, enter the following information:
o JNDI name: jdbc/playerDB
o Database connection : select jdbc:derby://localhost:1527/playerDB[john on JOHN]
b. Click OK.

The PLAYER and TEAM tables are displayed under the Available Tables column.
c. Click Add All. The PLAYER and TEAM tables are displayed under the Selected Tables column.
d. Click Next.

4. In the Entity Classes window, complete the following steps:


a. Enter the package name as com.playerentity.
b. Click Next.

5. In the Generated Classes Window, click Finish with default values.

Test RESTful web Services


1. To Generate Web Services Test client, complete the following steps.
a. Select PlayerServer project.
b. Right-click and select Test RESTful Web Services.
2. Select "Web Test Client in project" and click Browse.
3. a. In the Select Project dialog box, select PlayerServer and click OK.
b. Configure Rest Test Client window is displayed, click OK.
Player Client
To create new Java Project, select File > New Project >Playerclient
Generating Entity Classes from Database

Implementing CRUD operations on the database, requires creation of Entity Classes to


communicate with the database. The following section demonstrates how to create Entity
Classes from database.

1. Right-click PlayerClient Project and select New > Entity Classes From Database.

2. a. In the Database Tables window, Database Connection field


select jdbc:derby://localhost:1527/playerDB[john on JOHN] from the drop-down list.

You see PLAYER and TEAM tables in Available Tables category


b. Click Add All
You see both the tables PLAYER and TEAM in Selected Tables Category.
c. Click Next

3. In the Entity classes Window, enter the Package Name as playerentities and click Next.
Create Client
Complete the following steps to create RESTful client in PlayerClient project.
a. Right-click the PlayerClient and choose New > Other > Web Services > RESTful Java Client.
b. Click Next.

1. a.Enter the following details for the fields in the New Restful Java Client window :
 Class Name: CreatePlayerJerseyClient
 Package: playerClient
 Select the REST resource: From Project and Click Browse.

b. Select PlayerServer.
c. Expand the PlayerServer application.
d. Select PlayerFacadeREST[com.playerentity.player].
2.Add the main method.
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);

GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};


List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));

Player p = new Player();


p.setFirstname("Harry");
p.setId(30);
p.setJerseynumber(60);
p.setLastname("Potter");
p.setLastspokenwords("Thanks to my fans");
client1.create_XML(p);
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};
List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Player players:data){
System.out.println("FirstName:"+players.getFirstname());
System.out.println("PlayerID:"+players.getId());
System.out.println("JerseyNo:"+players.getJerseynumber());
}
System.out.println("Data Retreived!!");
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("1");
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "2");
GenericType<Player>genericType = new GenericType<Player>(){};
Player player = response.getEntity(genericType);
System.out.println("First Name: "+player.getFirstname());
System.out.println("PlayerId: "+player.getId());
System.out.println("JerseyNo: "+player.getJerseynumber());
System.out.println("Last Name: "+player.getLastname());
System.out.println("Last Spoken Words: "+player.getLastspokenwords());
player.setJerseynumber(100);
player.setLastspokenwords("I will be retiring soon");
client1.edit_XML(player);
}
Practical No. 3B

 Develop Micro-blogger application (like Twitter) using RESTful Web services.


Blogger Server

Blogger Client
Create Client
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
Bloggerdb b = new Bloggerdb();
b.setMessageId(4);
b.setContent("Draco the Slytherine Champion");
b.setUsername("Draco");
b.setPassword("Malfoy");
client1.create_XML(b);
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "1");
GenericType<Bloggerdb>genericType = new GenericType<Bloggerdb>(){};
Bloggerdb b = response.getEntity(genericType);
System.out.println("Message id:"+b.getMessageId());
System.out.println("Content:"+b.getContent());
System.out.println("Username:"+b.getUsername());
System.out.println("Password:"+b.getPassword());
b.setContent("I love food");
client1.edit_XML(b);
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("4");
System.out.println("Successfully Deleted!!");
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Bloggerdb b:data){
System.out.println("Content: "+b.getContent());
System.out.println("Username: "+b.getUsername());
System.out.println("Password:"+b.getPassword());
}
System.out.println("Data Retreived!!");
}
Practical-4
Develop application to consume Google’s search / Google’s Map RESTful Web service.

PROGRAM: (GOOGLE’s MAP RESTFUL WEB SERVICE)

import requests

def get_geolocation(api_key, search_string):


base_url = "https://us1.locationiq.com/v1/search"
params = {
'key': api_key,
'q': search_string,
'format': 'json',
}

response = requests.get(base_url, params=params)


data = response.json()

if response.status_code == 200 and data:


result = {
'place_id': data[0].get('place_id', ''),
'lat': data[0].get('lat', ''),
'lon': data[0].get('lon', ''),
'display_name': data[0].get('display_name', ''),
}
return result
else:
print(f"Error: {response.status_code} - {data.get('error', 'No error message')}")
return None

api_key = 'pk.71c93f03731ac10faf75d7e071df51c1 '


search_string = input("Enter the location : ")

result = get_geolocation(api_key, search_string)

if result:
print("Output:")
for key, value in result.items():
print(f"{key}: {value}")

BROWSE LOCATION IQ>SIGNUP WITH EMAIL> CLICK ON THE LINK PROVIDED BY LOCATION IQ (on
your email)>YOU WILL GET YOUR ACCESS TOKEN COPY THE KEY AND PASTE IN THE PYTHON CODE:

RUN THE CODE


Output:
Practical-5
Installation and Configuration of virtualization using KVM

Aim : Installation and Configuration of Virtualization using KVM.


Prerequisite: 1.Virtual Box/Virtual Machine
2. Ubuntu iso file
Steps: Installation of Ubuntu Virtual Box
Step 1:Start the virtualBox and Click on New

Step 2: Now Give the name as Cloud_Computing


Select type Linux
Version Ubuntu(32bit)/Ubuntu64(bit)
And Select Virtual HardDisk
And Click on Create button
Step 3: Now start the Virual Machine and Select the Ubuntu iso file and click on start
Now see the below ScreenShots for installation
Step4 : Now open the terminal and perform the following command
sudogrep -c "svm\|vmx" /proc/cpuinfo

sudo apt-get install qemu-kvmlibvirt-bin bridge-utilsvirt-manager

Sudoadduser shraddha
Sudoadduser shraddha libvirtd

virsh -c qemu:///system list

Virt-manager
Click on new virtual machine in qemu and perform the following step
After that you will get final output
Practical-6
Develop application to download image/video from server or upload image/videoto 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(filename, imageBytes);
bis.close();
out.println("File uploaded :"+filePath);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
>
<%-- end web service invocation --><hr/>

<%-- 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);
}
}
@WebMethod(operationName = "download")
public byte[] download(@WebParam(name = "Filename") String Filename) {
String filePath="C:/MSC/upload/"+Filename;
System.out.println("Sending 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;
}
}
Output:
Practical-07
Aim: Develop client which consumes web services developed in different platform.
Create a webservice in netbean and use it in .NET
Open Netbeans 8.2 – file—new- progect
Right Click on FactorialWebService project->New->Web Service

Go to design page--Add operation


Give method name as factorial
Return type double
Parameter num
Type double
Go to source page and Now type the code below in Factorialwebservice.java file
@WebMethod(operationName ="factorial")

public Double factorial(double num){

double f=1;

int i;

for(i=1;i<=num;i++){

f= f*i;

return f;

}
Right click on project name FactorialWebService->clean and build
Right click on project name FactorialWebService ->deploy
Right click on FactorialWebService ---test web service

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

Steps to create the Client app in .NET


Open Visual Studio 2010 ----file—new project
1:- Create a New Project in C# Empty Web Application

Steps to create the Client app in .NET

1:- Create a New Project in C# Empty Web Application


2:- Add a new Empty Web
3:- Design the interface and give the appropriate name and id's

4:- clean and build , and deploy the webservice created in the java and Test the WebService

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

5:- Now RightClick on Progect name and add (Service Reference in Client app) and paste the WSDL url
6:- Now doubleclick the button and then type the following cod in the aspx.cs file

protected void Button1_Click(object sender, EventArgs e)


{

ServiceReference1.FactorialwebserviceClient client =
new ServiceReference1.FactorialwebserviceClient();

Label1.Text = "Factorial is : " +


client.factorial(Convert.ToDouble(TextBox1.Text)).ToString();

Note:- here the name of the web service "factorialWebserviceClient" is created in


java.

output:-
Practical-08
Implement FOSS-Cloud Functionality VSI (Virtual Server Infrastructure) Infrastructure as a Service (IaaS),
Creating Virtual Machine or Storage

FOSS Cloud Installation

Steps:

1. Choose your keymap. 2. Confirm that you want to start: yes

3. Choose Demo-System: 1

4. Choose a Block-Device: sda

5. Confirm that you want to continue: yes

6. Confirm that you want to continue: yes

7. Choose the network interface: eth0

8. Choose if you want to use automatic network configuration: Yes

9. Reboot your system: yes

10. Login as root and run "fc-node-configuration -n demo-system --password admin"

Note :- Above mentioned steps aren’t mandatory you can start with the installation process of
virt-viewer as shown below.

1. Install virt-viewer.

2. Install spice-client.0.6.3.

3. Open Browser.

 Once you open browser then on the search type, 192.168.21.36


 Uploading ISO files to Foss cloud

Go to virtual machineProfile Upload ISO filefile name

Now choose the ubuntu-16.04.5-desktop-i386 iso-file from the FOSS cloud folder. Then, give
your desired file name to it and click on the upload button.
Once done with the upload process go to the create section in profiles.
Creating a Profile
The profile creates the relationship between the ISO file and the FOSS-Cloud.
1. Open Virtual Machines
2. Choose VM-Profiles
3. Choose the right Base Profile
4. Choose the right architecture (Windows only x86_64)
5. Chose the language (it is a information - not keyboard relevant)
6. Choose the ISO file (which you gave in file name tab)
7. Fill out name and description
8. Choose the amount of memory and volume capacity
9. Choose amount of CPU
10. Choose clock offset (normally Windows is "localtime" and Linux is "utc")
Now, we will create a VM template.
Creating Template
1. Choose the profile you have prepared before.
2. Add the VM-pool and one or more nodes, where you will run this VM (when the chosen VM-
pool has only one node assigned, you don't have a choice)
3. You can change all the other information you have entered before
Click on "create" and the template is ready for installing the guest operating system.
Once you create your virtual machine template you will be able to see your VM template.

As you can see the last row of Display column our template is created.

To update your template status, click on the green arrow.


Now click on Use Template in Action column of your corresponding template.

Just after clicking on, it a pop up would appear to Open remote-viewer? click on Open-remote-
viewer button, you will see the following screen.
Note :- If you don't see the above screen follow the below given steps.
1.First press window + r, then type regedit and click ok.

2. Further permissions tab will open then click yes, and a regedit editor will get open.

3. In the Registry Editor a list of directories would appear, in those lists of directories search
for the spice directory.
4. Keep on expanding the spice directory until you reach the command section.
5. Then click on the default file and a pop up will appear, then you have to paste the path
C:\Users\ADMIN\AppData\Local\virt-viewer\bin in the value data and also type %1 in last.
Once done the above screen will appear.

Finally, after clicking on remote viewer button a command line come where a graphical control
loading and getting connected will be displayed and then finally the ubuntu will get open.
On opening of ubuntu click on try ubuntu. Now, you can use ubuntu on your virtual machine.
Practical-09

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.

Installationof Netbeans, Eclipse, Visual Studio and DBMS can be done in the appropriate Virtual
Aim: Implement FOSS-Cloud Functionality VSI Software as a Service (SaaS)

Applications created and deployed in the virtual machines can be accessed by outside world.

This can be implemented as Software as Service.


Practical 10
Aim: Write a program to implement to create a simple web service that converts the temperature
from Fahrenheit to Celsius and vice a versa.

Step 1 select java web application

Open Netbeans 8/8.2 --- file --- new project --- java web (left) --- web application(right)

Give name – tempwebservice

Step 2 select web service

Right click on project name tempwebservice –new –other –web service


Step 3

Go to Design page ---- add operation


tempservice.java

package mypack;

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.WebParam;

@WebService(serviceName = "tempservice")

public class tempservice {

@WebMethod(operationName = "hello")

public String hello(@WebParam(name = "name") String txt)

return "Hello " + txt + " !";

@WebMethod(operationName = "F_to_C")

public Double F_to_C(@WebParam(name = "val") double val)

return ((val-32)*5/9);

@WebMethod(operationName = "C_to_F")

public Double C_to_F(@WebParam(name = "val") double val) {


return (val*9/5)+32;

Step 4 run

Right click on project name tempwebservice--- deploy

Right click on tempservice---test web service


in output window go to WSDL File and copy the url from address bar

URL http://localhost:8080/tempwebservice/tempWebService?WSDL

Steps to create Web Service Client:

• File-> New Project


Right click on project->New->Web Service Client-> Add the WSDL URL
Explore Web services References->and drag drop method which you want to call

//TempClient.java

package tempclient;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class TempClient {

public static void main(String[] args) throws IOException {

Double t;

int ch;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("1. Celcius to Fahreheit");

System.out.println("2. Fahrenheit to celcius");

System.out.println("Enter your Choice");

ch=Integer.parseInt(br.readLine());

System.out.println("Enter temperature");

t=Double.parseDouble(br.readLine());

if(ch==1)
System.out.println("temperature in fahrenheit="+cToF(t));

else

System.out.println("Temperature in celcius="+fToC(t));

private static Double cToF(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.cToF(val);

private static Double fToC(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.fToC(val);

O/P:

1. Celcius to Fahreheit

2. Fahrenheit to celcius
Enter your Choice

1
Enter temperature

25
temperature in fahrenheit=77.0
K.M.AGRAWAL COLLEGE OF ARTS, COMMERCE
AND SCIENCE

KALYAN

NAAC ACCREDITED B++

CERTIFICATE
This is to certify that Mr./Ms.____________________________________________Exam Seat
No__________________ has satisfactorily completed the Journal on
_________________________________________________for partial fulfillment of the 3
year Full Time Course Bachelor of Computer Science (SEM-VI) of the University of Mumbai
forthe year 2023-2024.

Exam Seat No:___________ Roll No.: ___________

Place : KALYAN Date : / /

Prof. In-Charge In-Charge External Examiner Signature


Self-Finance Department
INDEX

Sr.No Date Practical List Sign.


1. 10/01/24 Create a Simple SOAP service

2. 24/01/24 Create restfull web service

3. A] 3/01/24 A] Create a Simple REST Service

3. B] 3/01/24 B] Develop Micro-blogger application (like Twitter) using


RESTful Web services.

4. 07/02/24 Develop application to consume Google’s search /


Google’s Map RESTful Webservice.

5. 21/02/24 Installation and Configuration of virtualization using KVM

6. 28/02/24 Develop application to download image/video from server or


upload image/videoto server using MTOM techniques

7. 13/03/24 Develop client which consumes web services developed in


different platform. Create a webservice in netbean and use it
in .NET

8. 20/03/24 Implement FOSS-Cloud Functionality VSI (Virtual Server


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

9. 27/03/24 Implement FOSS-Cloud Functionality - VSI Platform as a


Service (PaaS)

10. 03/04/24 Write a program to implement to create a simple web service


that converts the temperature from Fahrenheit to Celsius and
vice a versa.
TYCS SEM-VI Cloud Computing and Web Services Journal

Practical-1
Create a Simple SOAP service.

Steps:
1] Open the NetBeans , and you will get the following screen. Close the start page.

2] Now click on the file tab and click on new project you will get the following screen :
TYCS SEM-VI Cloud Computing and Web Services Journal

3] In Categories select Java Web and in Projects , Select Web Application .After selecting click onnext .
You will get the following window:

4] Now Give name to the Project Name: , and click on next . you will get the following windowthen
. again click on finish:
TYCS SEM-VI Cloud Computing and Web Services Journal

5] You will get the following screen now carefully see in projects section your recently created project
appears double click to expand it:

6] Now Right click on the project and select new and then select Web Service ,As shown Below:
TYCS SEM-VI Cloud Computing and Web Services Journal

7] after clicking Web Service following window should appear , now give name to web serviceand
give package as “server”. As shown in the image:

After clicking finish you should get the following window erase the mentioned code :

8] Now right click any where and click on insert code and select Add Web Service Operation :
9] the following window would appear :
Just give name to the method or operation and click on add button to add parameters to the method as
here we are converting dollar to rupees we should need only one parameter .

10] give the name to the variable select data type as double and click on ok as shown below:
11] After clicking ok code will autogenerate , make changes In that code as mentioned below:

12] now our web service is ready now right click on project and click on deploy :

13] now right click on webservice and click on test web service you will get the following output:
https://study.cscornersunitarai.com/ https://www.youtube.com/@cscornersunitarai

TYCS SEM-VI Cloud Computing and Webservices Journal

So this is how we created our web service and deployed it.


TYCS SEM-VI Cloud Computing and Webservices Journal

Creating a java Client using jsp

14] now our web service is successfully deployed. Right click on web pages and select new and
select jsp as shown below:

15] give name and click on finish as shown below do it 2 times on for input and one foroutput:

16] In input.jsp create a form for taking user input as shown below:
In this code set action = the jsp file where u want output and give name to textbox input.

17] now we have to create web service client, for same right click on project and select new then
select web service client you will get the following screen:

At this step click on browse and select your project and click ok after clicking ok you will get wsdl url as
shown below:
At this stage copy the url and paste it in notepad for future.
Give package name as “Client”.

Now click on finish.

18] now in project section you can se a new folder is been created named “web servicerefrence”.
double click to expand it you should get the following :
Hold the operation or your operation name and drag it into the output.jsp in body tag as shown
: You will get the following auto generated code:

19] now make changes as shown below in the code:

20] now Deploy our project again and right click on input.jsp and click run file you will redirect to a
browser page as shown :
Enter any numerical value in text box and click on submit you will get the following output:
Python client:

1] for consuming java web services in python we should repeat the above steps till step np.19 .

Note: for getting output the project or web service should be deployed .

After doing all of the steps write the following code in python idle:

Code :

from zeep import Client


wsdl_url='http://localhost:8080/pract/Currency?wsdl'
client=Client(wsdl_url)

#call the method on the webservice


d=float(input("Enter Currency in Indian Rupees:"))
result = client.service.InrtoDollar(d)
print(result)2] replace wsdl_url with the url which was copied at the time of web service client
creation .

In step no.17 . and replace the InrtoDollarwith your method or operation name. and pass parameter
to it

3] final code should look like following:

4] after running the above code you should get the following output:
.Net Client

1] open visual studio and select create a new project the following window will appear:

Here in search bar type “console c#” and select console app for .Net frame work as shown in
above image.

2] Give name to the project and press create button as shown in the image:
This window should appear after clicking create button now In right side there is solution Explorer.

In that right click on your project name and click on add > Service Reference . You will get the
following window :

Note: before executing the code make sure that the web service is deployed.

Here in address bar paste the wsdl url the same which is used I python code. And press go button . agter
set the namespace In my case I am letting is as it is then press ok button.
In following image u can check in solution Explorer service refrence iscreated.:
3] now in code write the following line as shown in image:

Here type:
Using your_projectname . your_serviceReference_name ;

4] now write the code as shown in the following image:


Note:

Here CurrencyClient is my webservice class name and operation() is my method name as show
you can also check your own:

5] when you run the above code you get the following output:
Practical-2

Create restfull web service


Open Mysql command lie client
Type the following code

Create database mydbs2;


Use mydbs2;
CREATE TABLE emp1( eid INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20),dept VARCHAR(55));

Open netbeans
Take new project-----java web(left)----new application(right)
Practical-3A

Create a Simple REST Service

 Demonstrate CRUD operations with suitable database using RESTful Web service.

1. To start the Java DB Database from NetBeans, perform the following steps.

Click Services tab -> Expand Databases node. ->Right-click Java DB icon.

->Select Start Server

2. To create playerDB database, perform the following steps:

a. Right-click Java DB icon, select Create Database.


b. Enter the following information for the database:

Database Name:
playerDBUser Name:
john Password: john
Confirm Password:john

c. Click OK.

3. To connect to the newly created database playerDB, perform the following steps

a. Right-click jdbc:derby://localhost:1527/playerDB connection.

b. Select Connect.

4. Create tables and populate them with data in playerDB database.

a. In NetBeans select File > Open File.

b.In the file select playersDB.sql.

c. Click Open. The script automatically opens in the SQL Editor.

5. Examine the contents of the database.

a. In the Services window, expand the jdbc:derby://localhost:1527/playerDB connection


underthe Databases node.
b. Right-click the connection and select Refresh.
c. Expand the john schema. You see the nodes for Tables, Views, and Procedures. d.
Expand the Tables node to see the PLAYER and TEAM tables. e. Right-click the
PLAYER table node and select View Data.

Player server
To create RESTful Web Services, you need a Java Web application project. In the below section you
willcreate a demo Java web project, PlayerServer.
To create new Java Web Project, select File -> New Project -> Java web -> Web Application.
Generating web service
To generate RESTful Web Services do the following:
1.Right-click the PlayerServer and choose New > Other > Web Services > RESTful Web Services from
Database. The New RESTful Web Service wizard opens on the Database Tables panel.
2. In the Database Tables window, select Data Source.

3. Next select "New Data Source" from the Drop-down list.


a. In the Create Data Source Window, enter the following information:
o JNDI name: jdbc/playerDB
o Database connection : select jdbc:derby://localhost:1527/playerDB[john on JOHN]
b. Click OK.

The PLAYER and TEAM tables are displayed under the Available Tables column.
c. Click Add All. The PLAYER and TEAM tables are displayed under the Selected Tables column.
d. Click Next.

4. In the Entity Classes window, complete the following steps:


a. Enter the package name as com.playerentity.
b. Click Next.

5. In the Generated Classes Window, click Finish with default values.

Test RESTful web Services


1. To Generate Web Services Test client, complete the following steps.
a. Select PlayerServer project.
b. Right-click and select Test RESTful Web Services.
2. Select "Web Test Client in project" and click Browse.
3. a. In the Select Project dialog box, select PlayerServer and click OK.
b. Configure Rest Test Client window is displayed, click OK.
Player Client
To create new Java Project, select File > New Project >Playerclient
Generating Entity Classes from Database

Implementing CRUD operations on the database, requires creation of Entity Classes to


communicate with the database. The following section demonstrates how to create Entity
Classes from database.

1. Right-click PlayerClient Project and select New > Entity Classes From Database.

2. a. In the Database Tables window, Database Connection field


select jdbc:derby://localhost:1527/playerDB[john on JOHN] from the drop-down list.

You see PLAYER and TEAM tables in Available Tables category


b. Click Add All
You see both the tables PLAYER and TEAM in Selected Tables Category.
c. Click Next

3. In the Entity classes Window, enter the Package Name as playerentities and click Next.
Create Client
Complete the following steps to create RESTful client in PlayerClient project.
a. Right-click the PlayerClient and choose New > Other > Web Services > RESTful Java Client.
b. Click Next.

1. a.Enter the following details for the fields in the New Restful Java Client window :
 Class Name: CreatePlayerJerseyClient
 Package: playerClient
 Select the REST resource: From Project and Click Browse.

b. Select PlayerServer.
c. Expand the PlayerServer application.
d. Select PlayerFacadeREST[com.playerentity.player].
2.Add the main method.
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);

GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};


List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));

Player p = new Player();


p.setFirstname("Harry");
p.setId(30);
p.setJerseynumber(60);
p.setLastname("Potter");
p.setLastspokenwords("Thanks to my fans");
client1.create_XML(p);
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};
List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Player players:data){
System.out.println("FirstName:"+players.getFirstname());
System.out.println("PlayerID:"+players.getId());
System.out.println("JerseyNo:"+players.getJerseynumber());
}
System.out.println("Data Retreived!!");
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("1");
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "2");
GenericType<Player>genericType = new GenericType<Player>(){};
Player player = response.getEntity(genericType);
System.out.println("First Name: "+player.getFirstname());
System.out.println("PlayerId: "+player.getId());
System.out.println("JerseyNo: "+player.getJerseynumber());
System.out.println("Last Name: "+player.getLastname());
System.out.println("Last Spoken Words: "+player.getLastspokenwords());
player.setJerseynumber(100);
player.setLastspokenwords("I will be retiring soon");
client1.edit_XML(player);
}
Practical No. 3B

 Develop Micro-blogger application (like Twitter) using RESTful Web services.


Blogger Server

Blogger Client
Create Client
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
Bloggerdb b = new Bloggerdb();
b.setMessageId(4);
b.setContent("Draco the Slytherine Champion");
b.setUsername("Draco");
b.setPassword("Malfoy");
client1.create_XML(b);
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "1");
GenericType<Bloggerdb>genericType = new GenericType<Bloggerdb>(){};
Bloggerdb b = response.getEntity(genericType);
System.out.println("Message id:"+b.getMessageId());
System.out.println("Content:"+b.getContent());
System.out.println("Username:"+b.getUsername());
System.out.println("Password:"+b.getPassword());
b.setContent("I love food");
client1.edit_XML(b);
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("4");
System.out.println("Successfully Deleted!!");
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Bloggerdb b:data){
System.out.println("Content: "+b.getContent());
System.out.println("Username: "+b.getUsername());
System.out.println("Password:"+b.getPassword());
}
System.out.println("Data Retreived!!");
}
Practical-4
Develop application to consume Google’s search / Google’s Map RESTful Web service.

PROGRAM: (GOOGLE’s MAP RESTFUL WEB SERVICE)

import requests

def get_geolocation(api_key, search_string):


base_url = "https://us1.locationiq.com/v1/search"
params = {
'key': api_key,
'q': search_string,
'format': 'json',
}

response = requests.get(base_url, params=params)


data = response.json()

if response.status_code == 200 and data:


result = {
'place_id': data[0].get('place_id', ''),
'lat': data[0].get('lat', ''),
'lon': data[0].get('lon', ''),
'display_name': data[0].get('display_name', ''),
}
return result
else:
print(f"Error: {response.status_code} - {data.get('error', 'No error message')}")
return None

api_key = 'pk.71c93f03731ac10faf75d7e071df51c1 '


search_string = input("Enter the location : ")

result = get_geolocation(api_key, search_string)

if result:
print("Output:")
for key, value in result.items():
print(f"{key}: {value}")

BROWSE LOCATION IQ>SIGNUP WITH EMAIL> CLICK ON THE LINK PROVIDED BY LOCATION IQ (on
your email)>YOU WILL GET YOUR ACCESS TOKEN COPY THE KEY AND PASTE IN THE PYTHON CODE:

RUN THE CODE


Output:
Practical-5
Installation and Configuration of virtualization using KVM

Aim : Installation and Configuration of Virtualization using KVM.


Prerequisite: 1.Virtual Box/Virtual Machine
2. Ubuntu iso file
Steps: Installation of Ubuntu Virtual Box
Step 1:Start the virtualBox and Click on New

Step 2: Now Give the name as Cloud_Computing


Select type Linux
Version Ubuntu(32bit)/Ubuntu64(bit)
And Select Virtual HardDisk
And Click on Create button
Step 3: Now start the Virual Machine and Select the Ubuntu iso file and click on start
Now see the below ScreenShots for installation
Step4 : Now open the terminal and perform the following command
sudogrep -c "svm\|vmx" /proc/cpuinfo

sudo apt-get install qemu-kvmlibvirt-bin bridge-utilsvirt-manager

Sudoadduser shraddha
Sudoadduser shraddha libvirtd

virsh -c qemu:///system list

Virt-manager
Click on new virtual machine in qemu and perform the following step
After that you will get final output
Practical-6
Develop application to download image/video from server or upload image/videoto 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(filename, imageBytes);
bis.close();
out.println("File uploaded :"+filePath);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
>
<%-- end web service invocation --><hr/>

<%-- 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);
}
}
@WebMethod(operationName = "download")
public byte[] download(@WebParam(name = "Filename") String Filename) {
String filePath="C:/MSC/upload/"+Filename;
System.out.println("Sending 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;
}
}
Output:
Practical-07
Aim: Develop client which consumes web services developed in different platform.
Create a webservice in netbean and use it in .NET
Open Netbeans 8.2 – file—new- progect
Right Click on FactorialWebService project->New->Web Service

Go to design page--Add operation


Give method name as factorial
Return type double
Parameter num
Type double
Go to source page and Now type the code below in Factorialwebservice.java file
@WebMethod(operationName ="factorial")

public Double factorial(double num){

double f=1;

int i;

for(i=1;i<=num;i++){

f= f*i;

return f;

}
Right click on project name FactorialWebService->clean and build
Right click on project name FactorialWebService ->deploy
Right click on FactorialWebService ---test web service

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

Steps to create the Client app in .NET


Open Visual Studio 2010 ----file—new project
1:- Create a New Project in C# Empty Web Application

Steps to create the Client app in .NET

1:- Create a New Project in C# Empty Web Application


2:- Add a new Empty Web
3:- Design the interface and give the appropriate name and id's

4:- clean and build , and deploy the webservice created in the java and Test the WebService

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

5:- Now RightClick on Progect name and add (Service Reference in Client app) and paste the WSDL url
6:- Now doubleclick the button and then type the following cod in the aspx.cs file

protected void Button1_Click(object sender, EventArgs e)


{

ServiceReference1.FactorialwebserviceClient client =
new ServiceReference1.FactorialwebserviceClient();

Label1.Text = "Factorial is : " +


client.factorial(Convert.ToDouble(TextBox1.Text)).ToString();

Note:- here the name of the web service "factorialWebserviceClient" is created in


java.

output:-
Practical-08
Implement FOSS-Cloud Functionality VSI (Virtual Server Infrastructure) Infrastructure as a Service (IaaS),
Creating Virtual Machine or Storage

FOSS Cloud Installation

Steps:

1. Choose your keymap. 2. Confirm that you want to start: yes

3. Choose Demo-System: 1

4. Choose a Block-Device: sda

5. Confirm that you want to continue: yes

6. Confirm that you want to continue: yes

7. Choose the network interface: eth0

8. Choose if you want to use automatic network configuration: Yes

9. Reboot your system: yes

10. Login as root and run "fc-node-configuration -n demo-system --password admin"

Note :- Above mentioned steps aren’t mandatory you can start with the installation process of
virt-viewer as shown below.

1. Install virt-viewer.

2. Install spice-client.0.6.3.

3. Open Browser.

 Once you open browser then on the search type, 192.168.21.36


 Uploading ISO files to Foss cloud

Go to virtual machineProfile Upload ISO filefile name

Now choose the ubuntu-16.04.5-desktop-i386 iso-file from the FOSS cloud folder. Then, give
your desired file name to it and click on the upload button.
Once done with the upload process go to the create section in profiles.
Creating a Profile
The profile creates the relationship between the ISO file and the FOSS-Cloud.
1. Open Virtual Machines
2. Choose VM-Profiles
3. Choose the right Base Profile
4. Choose the right architecture (Windows only x86_64)
5. Chose the language (it is a information - not keyboard relevant)
6. Choose the ISO file (which you gave in file name tab)
7. Fill out name and description
8. Choose the amount of memory and volume capacity
9. Choose amount of CPU
10. Choose clock offset (normally Windows is "localtime" and Linux is "utc")
Now, we will create a VM template.
Creating Template
1. Choose the profile you have prepared before.
2. Add the VM-pool and one or more nodes, where you will run this VM (when the chosen VM-
pool has only one node assigned, you don't have a choice)
3. You can change all the other information you have entered before
Click on "create" and the template is ready for installing the guest operating system.
Once you create your virtual machine template you will be able to see your VM template.

As you can see the last row of Display column our template is created.

To update your template status, click on the green arrow.


Now click on Use Template in Action column of your corresponding template.

Just after clicking on, it a pop up would appear to Open remote-viewer? click on Open-remote-
viewer button, you will see the following screen.
Note :- If you don't see the above screen follow the below given steps.
1.First press window + r, then type regedit and click ok.

2. Further permissions tab will open then click yes, and a regedit editor will get open.

3. In the Registry Editor a list of directories would appear, in those lists of directories search
for the spice directory.
4. Keep on expanding the spice directory until you reach the command section.
5. Then click on the default file and a pop up will appear, then you have to paste the path
C:\Users\ADMIN\AppData\Local\virt-viewer\bin in the value data and also type %1 in last.
Once done the above screen will appear.

Finally, after clicking on remote viewer button a command line come where a graphical control
loading and getting connected will be displayed and then finally the ubuntu will get open.
On opening of ubuntu click on try ubuntu. Now, you can use ubuntu on your virtual machine.
Practical-09

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.

Installationof Netbeans, Eclipse, Visual Studio and DBMS can be done in the appropriate Virtual
Aim: Implement FOSS-Cloud Functionality VSI Software as a Service (SaaS)

Applications created and deployed in the virtual machines can be accessed by outside world.

This can be implemented as Software as Service.


Practical 10
Aim: Write a program to implement to create a simple web service that converts the temperature
from Fahrenheit to Celsius and vice a versa.

Step 1 select java web application

Open Netbeans 8/8.2 --- file --- new project --- java web (left) --- web application(right)

Give name – tempwebservice

Step 2 select web service

Right click on project name tempwebservice –new –other –web service


Step 3

Go to Design page ---- add operation


tempservice.java

package mypack;

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.WebParam;

@WebService(serviceName = "tempservice")

public class tempservice {

@WebMethod(operationName = "hello")

public String hello(@WebParam(name = "name") String txt)

return "Hello " + txt + " !";

@WebMethod(operationName = "F_to_C")

public Double F_to_C(@WebParam(name = "val") double val)

return ((val-32)*5/9);

@WebMethod(operationName = "C_to_F")

public Double C_to_F(@WebParam(name = "val") double val) {


return (val*9/5)+32;

Step 4 run

Right click on project name tempwebservice--- deploy

Right click on tempservice---test web service


in output window go to WSDL File and copy the url from address bar

URL http://localhost:8080/tempwebservice/tempWebService?WSDL

Steps to create Web Service Client:

• File-> New Project


Right click on project->New->Web Service Client-> Add the WSDL URL
Explore Web services References->and drag drop method which you want to call

//TempClient.java

package tempclient;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class TempClient {

public static void main(String[] args) throws IOException {

Double t;

int ch;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("1. Celcius to Fahreheit");

System.out.println("2. Fahrenheit to celcius");

System.out.println("Enter your Choice");

ch=Integer.parseInt(br.readLine());

System.out.println("Enter temperature");

t=Double.parseDouble(br.readLine());

if(ch==1)
System.out.println("temperature in fahrenheit="+cToF(t));

else

System.out.println("Temperature in celcius="+fToC(t));

private static Double cToF(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.cToF(val);

private static Double fToC(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.fToC(val);

O/P:

1. Celcius to Fahreheit

2. Fahrenheit to celcius
Enter your Choice

1
Enter temperature

25
temperature in fahrenheit=77.0
K.M.AGRAWAL COLLEGE OF ARTS, COMMERCE
AND SCIENCE

KALYAN

NAAC ACCREDITED B++

CERTIFICATE
This is to certify that Mr./Ms.____________________________________________Exam Seat
No__________________ has satisfactorily completed the Journal on
_________________________________________________for partial fulfillment of the 3
year Full Time Course Bachelor of Computer Science (SEM-VI) of the University of Mumbai
forthe year 2023-2024.

Exam Seat No:___________ Roll No.: ___________

Place : KALYAN Date : / /

Prof. In-Charge In-Charge External Examiner Signature


Self-Finance Department
INDEX

Sr.No Date Practical List Sign.


1. 10/01/24 Create a Simple SOAP service

2. 24/01/24 Create restfull web service

3. A] 3/01/24 A] Create a Simple REST Service

3. B] 3/01/24 B] Develop Micro-blogger application (like Twitter) using


RESTful Web services.

4. 07/02/24 Develop application to consume Google’s search /


Google’s Map RESTful Webservice.

5. 21/02/24 Installation and Configuration of virtualization using KVM

6. 28/02/24 Develop application to download image/video from server or


upload image/videoto server using MTOM techniques

7. 13/03/24 Develop client which consumes web services developed in


different platform. Create a webservice in netbean and use it
in .NET

8. 20/03/24 Implement FOSS-Cloud Functionality VSI (Virtual Server


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

9. 27/03/24 Implement FOSS-Cloud Functionality - VSI Platform as a


Service (PaaS)

10. 03/04/24 Write a program to implement to create a simple web service


that converts the temperature from Fahrenheit to Celsius and
vice a versa.
TYCS SEM-VI Cloud Computing and Web Services Journal

Practical-1
Create a Simple SOAP service.

Steps:
1] Open the NetBeans , and you will get the following screen. Close the start page.

2] Now click on the file tab and click on new project you will get the following screen :
TYCS SEM-VI Cloud Computing and Web Services Journal

3] In Categories select Java Web and in Projects , Select Web Application .After selecting click onnext .
You will get the following window:

4] Now Give name to the Project Name: , and click on next . you will get the following windowthen
. again click on finish:
TYCS SEM-VI Cloud Computing and Web Services Journal

5] You will get the following screen now carefully see in projects section your recently created project
appears double click to expand it:

6] Now Right click on the project and select new and then select Web Service ,As shown Below:
TYCS SEM-VI Cloud Computing and Web Services Journal

7] after clicking Web Service following window should appear , now give name to web serviceand
give package as “server”. As shown in the image:

After clicking finish you should get the following window erase the mentioned code :

8] Now right click any where and click on insert code and select Add Web Service Operation :
9] the following window would appear :
Just give name to the method or operation and click on add button to add parameters to the method as
here we are converting dollar to rupees we should need only one parameter .

10] give the name to the variable select data type as double and click on ok as shown below:
11] After clicking ok code will autogenerate , make changes In that code as mentioned below:

12] now our web service is ready now right click on project and click on deploy :

13] now right click on webservice and click on test web service you will get the following output:
https://study.cscornersunitarai.com/ https://www.youtube.com/@cscornersunitarai

TYCS SEM-VI Cloud Computing and Webservices Journal

So this is how we created our web service and deployed it.


TYCS SEM-VI Cloud Computing and Webservices Journal

Creating a java Client using jsp

14] now our web service is successfully deployed. Right click on web pages and select new and
select jsp as shown below:

15] give name and click on finish as shown below do it 2 times on for input and one foroutput:

16] In input.jsp create a form for taking user input as shown below:
In this code set action = the jsp file where u want output and give name to textbox input.

17] now we have to create web service client, for same right click on project and select new then
select web service client you will get the following screen:

At this step click on browse and select your project and click ok after clicking ok you will get wsdl url as
shown below:
At this stage copy the url and paste it in notepad for future.
Give package name as “Client”.

Now click on finish.

18] now in project section you can se a new folder is been created named “web servicerefrence”.
double click to expand it you should get the following :
Hold the operation or your operation name and drag it into the output.jsp in body tag as shown
: You will get the following auto generated code:

19] now make changes as shown below in the code:

20] now Deploy our project again and right click on input.jsp and click run file you will redirect to a
browser page as shown :
Enter any numerical value in text box and click on submit you will get the following output:
Python client:

1] for consuming java web services in python we should repeat the above steps till step np.19 .

Note: for getting output the project or web service should be deployed .

After doing all of the steps write the following code in python idle:

Code :

from zeep import Client


wsdl_url='http://localhost:8080/pract/Currency?wsdl'
client=Client(wsdl_url)

#call the method on the webservice


d=float(input("Enter Currency in Indian Rupees:"))
result = client.service.InrtoDollar(d)
print(result)2] replace wsdl_url with the url which was copied at the time of web service client
creation .

In step no.17 . and replace the InrtoDollarwith your method or operation name. and pass parameter
to it

3] final code should look like following:

4] after running the above code you should get the following output:
.Net Client

1] open visual studio and select create a new project the following window will appear:

Here in search bar type “console c#” and select console app for .Net frame work as shown in
above image.

2] Give name to the project and press create button as shown in the image:
This window should appear after clicking create button now In right side there is solution Explorer.

In that right click on your project name and click on add > Service Reference . You will get the
following window :

Note: before executing the code make sure that the web service is deployed.

Here in address bar paste the wsdl url the same which is used I python code. And press go button . agter
set the namespace In my case I am letting is as it is then press ok button.
In following image u can check in solution Explorer service refrence iscreated.:
3] now in code write the following line as shown in image:

Here type:
Using your_projectname . your_serviceReference_name ;

4] now write the code as shown in the following image:


Note:

Here CurrencyClient is my webservice class name and operation() is my method name as show
you can also check your own:

5] when you run the above code you get the following output:
Practical-2

Create restfull web service


Open Mysql command lie client
Type the following code

Create database mydbs2;


Use mydbs2;
CREATE TABLE emp1( eid INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20),dept VARCHAR(55));

Open netbeans
Take new project-----java web(left)----new application(right)
Practical-3A

Create a Simple REST Service

 Demonstrate CRUD operations with suitable database using RESTful Web service.

1. To start the Java DB Database from NetBeans, perform the following steps.

Click Services tab -> Expand Databases node. ->Right-click Java DB icon.

->Select Start Server

2. To create playerDB database, perform the following steps:

a. Right-click Java DB icon, select Create Database.


b. Enter the following information for the database:

Database Name:
playerDBUser Name:
john Password: john
Confirm Password:john

c. Click OK.

3. To connect to the newly created database playerDB, perform the following steps

a. Right-click jdbc:derby://localhost:1527/playerDB connection.

b. Select Connect.

4. Create tables and populate them with data in playerDB database.

a. In NetBeans select File > Open File.

b.In the file select playersDB.sql.

c. Click Open. The script automatically opens in the SQL Editor.

5. Examine the contents of the database.

a. In the Services window, expand the jdbc:derby://localhost:1527/playerDB connection


underthe Databases node.
b. Right-click the connection and select Refresh.
c. Expand the john schema. You see the nodes for Tables, Views, and Procedures. d.
Expand the Tables node to see the PLAYER and TEAM tables. e. Right-click the
PLAYER table node and select View Data.

Player server
To create RESTful Web Services, you need a Java Web application project. In the below section you
willcreate a demo Java web project, PlayerServer.
To create new Java Web Project, select File -> New Project -> Java web -> Web Application.
Generating web service
To generate RESTful Web Services do the following:
1.Right-click the PlayerServer and choose New > Other > Web Services > RESTful Web Services from
Database. The New RESTful Web Service wizard opens on the Database Tables panel.
2. In the Database Tables window, select Data Source.

3. Next select "New Data Source" from the Drop-down list.


a. In the Create Data Source Window, enter the following information:
o JNDI name: jdbc/playerDB
o Database connection : select jdbc:derby://localhost:1527/playerDB[john on JOHN]
b. Click OK.

The PLAYER and TEAM tables are displayed under the Available Tables column.
c. Click Add All. The PLAYER and TEAM tables are displayed under the Selected Tables column.
d. Click Next.

4. In the Entity Classes window, complete the following steps:


a. Enter the package name as com.playerentity.
b. Click Next.

5. In the Generated Classes Window, click Finish with default values.

Test RESTful web Services


1. To Generate Web Services Test client, complete the following steps.
a. Select PlayerServer project.
b. Right-click and select Test RESTful Web Services.
2. Select "Web Test Client in project" and click Browse.
3. a. In the Select Project dialog box, select PlayerServer and click OK.
b. Configure Rest Test Client window is displayed, click OK.
Player Client
To create new Java Project, select File > New Project >Playerclient
Generating Entity Classes from Database

Implementing CRUD operations on the database, requires creation of Entity Classes to


communicate with the database. The following section demonstrates how to create Entity
Classes from database.

1. Right-click PlayerClient Project and select New > Entity Classes From Database.

2. a. In the Database Tables window, Database Connection field


select jdbc:derby://localhost:1527/playerDB[john on JOHN] from the drop-down list.

You see PLAYER and TEAM tables in Available Tables category


b. Click Add All
You see both the tables PLAYER and TEAM in Selected Tables Category.
c. Click Next

3. In the Entity classes Window, enter the Package Name as playerentities and click Next.
Create Client
Complete the following steps to create RESTful client in PlayerClient project.
a. Right-click the PlayerClient and choose New > Other > Web Services > RESTful Java Client.
b. Click Next.

1. a.Enter the following details for the fields in the New Restful Java Client window :
 Class Name: CreatePlayerJerseyClient
 Package: playerClient
 Select the REST resource: From Project and Click Browse.

b. Select PlayerServer.
c. Expand the PlayerServer application.
d. Select PlayerFacadeREST[com.playerentity.player].
2.Add the main method.
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);

GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};


List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));

Player p = new Player();


p.setFirstname("Harry");
p.setId(30);
p.setJerseynumber(60);
p.setLastname("Potter");
p.setLastspokenwords("Thanks to my fans");
client1.create_XML(p);
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Player>> genericType = new GenericType<List<Player>>(){};
List<Player> data = new ArrayList<Player>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Player players:data){
System.out.println("FirstName:"+players.getFirstname());
System.out.println("PlayerID:"+players.getId());
System.out.println("JerseyNo:"+players.getJerseynumber());
}
System.out.println("Data Retreived!!");
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("1");
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "2");
GenericType<Player>genericType = new GenericType<Player>(){};
Player player = response.getEntity(genericType);
System.out.println("First Name: "+player.getFirstname());
System.out.println("PlayerId: "+player.getId());
System.out.println("JerseyNo: "+player.getJerseynumber());
System.out.println("Last Name: "+player.getLastname());
System.out.println("Last Spoken Words: "+player.getLastspokenwords());
player.setJerseynumber(100);
player.setLastspokenwords("I will be retiring soon");
client1.edit_XML(player);
}
Practical No. 3B

 Develop Micro-blogger application (like Twitter) using RESTful Web services.


Blogger Server

Blogger Client
Create Client
public static void main(String[]args){
CreateClient client1 = new CreateClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
Bloggerdb b = new Bloggerdb();
b.setMessageId(4);
b.setContent("Draco the Slytherine Champion");
b.setUsername("Draco");
b.setPassword("Malfoy");
client1.create_XML(b);
}

Update Client
public static void main(String[]args){
UpdateClient client1 = new UpdateClient();
ClientResponse response = client1.find_XML(ClientResponse.class, "1");
GenericType<Bloggerdb>genericType = new GenericType<Bloggerdb>(){};
Bloggerdb b = response.getEntity(genericType);
System.out.println("Message id:"+b.getMessageId());
System.out.println("Content:"+b.getContent());
System.out.println("Username:"+b.getUsername());
System.out.println("Password:"+b.getPassword());
b.setContent("I love food");
client1.edit_XML(b);
}
Delete Client
public static void main(String[]args){
DeleteClient client1 = new DeleteClient();
client1.remove("4");
System.out.println("Successfully Deleted!!");
}

Read Client
public static void main(String[]args){
ReadClient client1 = new ReadClient();
ClientResponse response = client1.findAll_XML(ClientResponse.class);
GenericType<List<Bloggerdb>> genericType = new GenericType<List<Bloggerdb>>(){};
List<Bloggerdb> data = new ArrayList<Bloggerdb>();
data = (response.getEntity(genericType));
System.out.println("Retreiving and Displaying Player Details");
for(Bloggerdb b:data){
System.out.println("Content: "+b.getContent());
System.out.println("Username: "+b.getUsername());
System.out.println("Password:"+b.getPassword());
}
System.out.println("Data Retreived!!");
}
Practical-4
Develop application to consume Google’s search / Google’s Map RESTful Web service.

PROGRAM: (GOOGLE’s MAP RESTFUL WEB SERVICE)

import requests

def get_geolocation(api_key, search_string):


base_url = "https://us1.locationiq.com/v1/search"
params = {
'key': api_key,
'q': search_string,
'format': 'json',
}

response = requests.get(base_url, params=params)


data = response.json()

if response.status_code == 200 and data:


result = {
'place_id': data[0].get('place_id', ''),
'lat': data[0].get('lat', ''),
'lon': data[0].get('lon', ''),
'display_name': data[0].get('display_name', ''),
}
return result
else:
print(f"Error: {response.status_code} - {data.get('error', 'No error message')}")
return None

api_key = 'pk.71c93f03731ac10faf75d7e071df51c1 '


search_string = input("Enter the location : ")

result = get_geolocation(api_key, search_string)

if result:
print("Output:")
for key, value in result.items():
print(f"{key}: {value}")

BROWSE LOCATION IQ>SIGNUP WITH EMAIL> CLICK ON THE LINK PROVIDED BY LOCATION IQ (on
your email)>YOU WILL GET YOUR ACCESS TOKEN COPY THE KEY AND PASTE IN THE PYTHON CODE:

RUN THE CODE


Output:
Practical-5
Installation and Configuration of virtualization using KVM

Aim : Installation and Configuration of Virtualization using KVM.


Prerequisite: 1.Virtual Box/Virtual Machine
2. Ubuntu iso file
Steps: Installation of Ubuntu Virtual Box
Step 1:Start the virtualBox and Click on New

Step 2: Now Give the name as Cloud_Computing


Select type Linux
Version Ubuntu(32bit)/Ubuntu64(bit)
And Select Virtual HardDisk
And Click on Create button
Step 3: Now start the Virual Machine and Select the Ubuntu iso file and click on start
Now see the below ScreenShots for installation
Step4 : Now open the terminal and perform the following command
sudogrep -c "svm\|vmx" /proc/cpuinfo

sudo apt-get install qemu-kvmlibvirt-bin bridge-utilsvirt-manager

Sudoadduser shraddha
Sudoadduser shraddha libvirtd

virsh -c qemu:///system list

Virt-manager
Click on new virtual machine in qemu and perform the following step
After that you will get final output
Practical-6
Develop application to download image/video from server or upload image/videoto 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(filename, imageBytes);
bis.close();
out.println("File uploaded :"+filePath);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
>
<%-- end web service invocation --><hr/>

<%-- 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);
}
}
@WebMethod(operationName = "download")
public byte[] download(@WebParam(name = "Filename") String Filename) {
String filePath="C:/MSC/upload/"+Filename;
System.out.println("Sending 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;
}
}
Output:
Practical-07
Aim: Develop client which consumes web services developed in different platform.
Create a webservice in netbean and use it in .NET
Open Netbeans 8.2 – file—new- progect
Right Click on FactorialWebService project->New->Web Service

Go to design page--Add operation


Give method name as factorial
Return type double
Parameter num
Type double
Go to source page and Now type the code below in Factorialwebservice.java file
@WebMethod(operationName ="factorial")

public Double factorial(double num){

double f=1;

int i;

for(i=1;i<=num;i++){

f= f*i;

return f;

}
Right click on project name FactorialWebService->clean and build
Right click on project name FactorialWebService ->deploy
Right click on FactorialWebService ---test web service

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

Steps to create the Client app in .NET


Open Visual Studio 2010 ----file—new project
1:- Create a New Project in C# Empty Web Application

Steps to create the Client app in .NET

1:- Create a New Project in C# Empty Web Application


2:- Add a new Empty Web
3:- Design the interface and give the appropriate name and id's

4:- clean and build , and deploy the webservice created in the java and Test the WebService

Copy the WSDL Link of the web service.

http://localhost:14188/FactorialWebservice/Factorialwebservice?WSDL

5:- Now RightClick on Progect name and add (Service Reference in Client app) and paste the WSDL url
6:- Now doubleclick the button and then type the following cod in the aspx.cs file

protected void Button1_Click(object sender, EventArgs e)


{

ServiceReference1.FactorialwebserviceClient client =
new ServiceReference1.FactorialwebserviceClient();

Label1.Text = "Factorial is : " +


client.factorial(Convert.ToDouble(TextBox1.Text)).ToString();

Note:- here the name of the web service "factorialWebserviceClient" is created in


java.

output:-
Practical-08
Implement FOSS-Cloud Functionality VSI (Virtual Server Infrastructure) Infrastructure as a Service (IaaS),
Creating Virtual Machine or Storage

FOSS Cloud Installation

Steps:

1. Choose your keymap. 2. Confirm that you want to start: yes

3. Choose Demo-System: 1

4. Choose a Block-Device: sda

5. Confirm that you want to continue: yes

6. Confirm that you want to continue: yes

7. Choose the network interface: eth0

8. Choose if you want to use automatic network configuration: Yes

9. Reboot your system: yes

10. Login as root and run "fc-node-configuration -n demo-system --password admin"

Note :- Above mentioned steps aren’t mandatory you can start with the installation process of
virt-viewer as shown below.

1. Install virt-viewer.

2. Install spice-client.0.6.3.

3. Open Browser.

 Once you open browser then on the search type, 192.168.21.36


 Uploading ISO files to Foss cloud

Go to virtual machineProfile Upload ISO filefile name

Now choose the ubuntu-16.04.5-desktop-i386 iso-file from the FOSS cloud folder. Then, give
your desired file name to it and click on the upload button.
Once done with the upload process go to the create section in profiles.
Creating a Profile
The profile creates the relationship between the ISO file and the FOSS-Cloud.
1. Open Virtual Machines
2. Choose VM-Profiles
3. Choose the right Base Profile
4. Choose the right architecture (Windows only x86_64)
5. Chose the language (it is a information - not keyboard relevant)
6. Choose the ISO file (which you gave in file name tab)
7. Fill out name and description
8. Choose the amount of memory and volume capacity
9. Choose amount of CPU
10. Choose clock offset (normally Windows is "localtime" and Linux is "utc")
Now, we will create a VM template.
Creating Template
1. Choose the profile you have prepared before.
2. Add the VM-pool and one or more nodes, where you will run this VM (when the chosen VM-
pool has only one node assigned, you don't have a choice)
3. You can change all the other information you have entered before
Click on "create" and the template is ready for installing the guest operating system.
Once you create your virtual machine template you will be able to see your VM template.

As you can see the last row of Display column our template is created.

To update your template status, click on the green arrow.


Now click on Use Template in Action column of your corresponding template.

Just after clicking on, it a pop up would appear to Open remote-viewer? click on Open-remote-
viewer button, you will see the following screen.
Note :- If you don't see the above screen follow the below given steps.
1.First press window + r, then type regedit and click ok.

2. Further permissions tab will open then click yes, and a regedit editor will get open.

3. In the Registry Editor a list of directories would appear, in those lists of directories search
for the spice directory.
4. Keep on expanding the spice directory until you reach the command section.
5. Then click on the default file and a pop up will appear, then you have to paste the path
C:\Users\ADMIN\AppData\Local\virt-viewer\bin in the value data and also type %1 in last.
Once done the above screen will appear.

Finally, after clicking on remote viewer button a command line come where a graphical control
loading and getting connected will be displayed and then finally the ubuntu will get open.
On opening of ubuntu click on try ubuntu. Now, you can use ubuntu on your virtual machine.
Practical-09

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.

Installationof Netbeans, Eclipse, Visual Studio and DBMS can be done in the appropriate Virtual
Aim: Implement FOSS-Cloud Functionality VSI Software as a Service (SaaS)

Applications created and deployed in the virtual machines can be accessed by outside world.

This can be implemented as Software as Service.


Practical 10
Aim: Write a program to implement to create a simple web service that converts the temperature
from Fahrenheit to Celsius and vice a versa.

Step 1 select java web application

Open Netbeans 8/8.2 --- file --- new project --- java web (left) --- web application(right)

Give name – tempwebservice

Step 2 select web service

Right click on project name tempwebservice –new –other –web service


Step 3

Go to Design page ---- add operation


tempservice.java

package mypack;

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.WebParam;

@WebService(serviceName = "tempservice")

public class tempservice {

@WebMethod(operationName = "hello")

public String hello(@WebParam(name = "name") String txt)

return "Hello " + txt + " !";

@WebMethod(operationName = "F_to_C")

public Double F_to_C(@WebParam(name = "val") double val)

return ((val-32)*5/9);

@WebMethod(operationName = "C_to_F")

public Double C_to_F(@WebParam(name = "val") double val) {


return (val*9/5)+32;

Step 4 run

Right click on project name tempwebservice--- deploy

Right click on tempservice---test web service


in output window go to WSDL File and copy the url from address bar

URL http://localhost:8080/tempwebservice/tempWebService?WSDL

Steps to create Web Service Client:

• File-> New Project


Right click on project->New->Web Service Client-> Add the WSDL URL
Explore Web services References->and drag drop method which you want to call

//TempClient.java

package tempclient;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class TempClient {

public static void main(String[] args) throws IOException {

Double t;

int ch;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("1. Celcius to Fahreheit");

System.out.println("2. Fahrenheit to celcius");

System.out.println("Enter your Choice");

ch=Integer.parseInt(br.readLine());

System.out.println("Enter temperature");

t=Double.parseDouble(br.readLine());

if(ch==1)
System.out.println("temperature in fahrenheit="+cToF(t));

else

System.out.println("Temperature in celcius="+fToC(t));

private static Double cToF(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.cToF(val);

private static Double fToC(double val) {

mypack.TempWebService_Service service = new mypack.TempWebService_Service();

mypack.TempWebService port = service.getTempWebServicePort();

return port.fToC(val);

O/P:

1. Celcius to Fahreheit

2. Fahrenheit to celcius
Enter your Choice

1
Enter temperature

25
temperature in fahrenheit=77.0

You might also like