Anda di halaman 1dari 44

www.Vidyarthiplus.

com

EX.No.:
Date :

CREATING A WEB SERVICE FOR CALCULATOR

Creating a Web Service

Choosing a Container

1. Choose File > New Project. Select Web Application from the Java Web category or
EJB Module from the Java EE category.
2. Name the project CalculWSApplication. Select a location for the project. Click Next.
3. Select your server and Java EE version and click Finish.

Creating a Web Service from a Java Class

1. Right-click the CalculatorWSApplication node and choose New > Web Service.
2. Name the web service CalculatorWS and type org.me.calculator in Package. Leave
Create Web Service from Scratch selected.
3. Click Finish. The Projects window displays the structure of the new web service and
the source code is shown in the editor area.

Adding an Operation to the Web Service

1. Find the web service's node in the Projects window. Right-click that node.
2. Click Add Operation in either the visual designer or the context menu.
3. In the upper part of the Add Operation dialog box, type add in Name and type int in
the Return Type drop-down list.
4. In the lower part of the Add Operation dialog box, click Add and create a
parameter of type int named i.
5. Click Add again and create a parameter of type int called j.
6. Click OK at the bottom of the Add Operation dialog box. You return to the editor.
7. Similar to sub, mul and div for the above steps.
8. Click Source and view the code that you generated.

package org.me.Calcul;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
/**
*
* @author 4itb21

www.vidyarthiplus.com
www.Vidyarthiplus.com

*/
@WebService(serviceName="CalculWSApplication")
@Stateless()
public class CalculWSApplication {
/**
* Web service operation
*/
@WebMethod(operationName = "Add")
public int Add(@WebParam(name = "i")
int i, @WebParam(name = "j")
int j) {
//TODO write your implementation code here:
int a=i+j;
return a;
}
/**
* Web service operation
*/
@WebMethod(operationName = "Sub")
public int Sub(@WebParam(name = "i")
int i, @WebParam(name = "j")
int j) {
//TODO write your implementation code here:
int s=i-j;
return s;
}
/**
* Web service operation
*/
@WebMethod(operationName = "Mul")
public int Mul(@WebParam(name = "i")
int i, @WebParam(name = "j")
int j) {
//TODO write your implementation code here:
int m=i*j;
return m;
}
/**
* Web service operation
*/
@WebMethod(operationName = "Div")
public int Div(@WebParam(name = "i")
int i, @WebParam(name = "j")

www.vidyarthiplus.com
www.Vidyarthiplus.com

int j) {
//TODO write your implementation code here:
int d=i/j;
return d; } }

Deploying and Testing the Web Service

1. Right-click the project and choose Deploy.


2. Right-click the CalculatorWS node, and choose Test Web Service.

CalculWSApplication Web Service Tester


This form will allow you to test your web service implementation (WSDL File)

To invoke an operation, fill the method parameter(s) input boxes and click on the
button labeled with the method name.

Methods :
public abstract int org.me.calcul.CalculWSApplication.add(int,int)
( , )

public abstract int org.me.calcul.CalculWSApplication.sub(int,int)


30 5
( , )

public abstract int org.me.calcul.CalculWSApplication.mul(int,int)


( , )

public abstract int org.me.calcul.CalculWSApplication.div(int,int)


( , )

sub Method invocation

Method parameter(s)
Type Value
int 30
int 5

Method returned
int : "25"

www.vidyarthiplus.com
www.Vidyarthiplus.com

SOAP Request

<?xml version="1.0" encoding="UTF-8"?>


<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:Sub xmlns:ns2="http://Calcul.me.org/">
<i>30</i>
<j>5</j>
</ns2:Sub>
</S:Body>
</S:Envelope>

SOAP Response

<?xml version="1.0" encoding="UTF-8"?>


<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:SubResponse xmlns:ns2="http://Calcul.me.org/">
<return>25</return>
</ns2:SubResponse>
</S:Body>
</S:Envelope>

Consuming the Web Service

1. Choose File > New Project. Select Java Application from the Java category. Name
the project CalculatorWS_Client_Application. Leave Create Main Class selected and
accept all other default settings. Click Finish.
2. Right-click the CalculatorWS_Client_Application node and choose New > Web Service
Client. The New Web Service Client wizard opens.
3. Select Project as the WSDL source. Click Browse. Browse to the CalculatorWS web
service in the CalculatorWSApplication project. When you have selected the web
service, and Leave the other settings at default and click Finish.
4. Double-click your main class so that it opens in the Source Editor. Drag the nodes
below the main() method.
5. Right-click the project node and choose Run

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package calculws_client_application;

www.vidyarthiplus.com
www.Vidyarthiplus.com

/**
*
* @author 4itb21
*/
public class CalculWS_Client_Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int i = 3;
int j = 4;
int result = add(i, j);
System.out.println("Result = " + result);
result = sub(i, j);
System.out.println("Result = " + result);
result = mul(i, j);
System.out.println("Result = " + result);
result = div(i, j);
System.out.println("Result = " + result);
}}
compile:
run:
Result = 7
Result = -1
Result = 12
Result = 0
BUILD SUCCESSFUL (total time: 1 second)

Result:
Thus the creation of webservice for calculator application has been executed
successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

EX.No.:
Date :

CREATING A WEB SERVICE FOR FINDING FACTORIAL

Creating a Web Service from a Java Class


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.meFactorial;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
/**
*
* @author 4itb21
*/
@WebService(serviceName="FactorialWS")
@Stateless()
public class FactorialWS {
/**
* Web service operation
*/
@WebMethod(operationName = "Fact")
public int Fact(@WebParam(name = "Fact")
int Fact) {
//TODO write your implementation code here:
int i,fact=1;
int number=5;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
return fact; } }

Deploying and Testing the Web Service

FactorialWS Web Service Tester


This form will allow you to test your web service implementation (WSDL File)

www.vidyarthiplus.com
www.Vidyarthiplus.com

To invoke an operation, fill the method parameter(s) input boxes and click on the
button labeled with the method name.
Methods :
public abstract int org.mefactorial.FactorialWS.fact(int)
5
( )

fact Method invocation

Method parameter(s)
Type Value
int 5

Method returned
int : "120"

SOAP Request

<?xml version="1.0" encoding="UTF-8"?>


<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:Fact xmlns:ns2="http://meFactorial.org/">
<Fact>5</Fact>
</ns2:Fact>
</S:Body>
</S:Envelope>

SOAP Response

<?xml version="1.0" encoding="UTF-8"?>


<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:FactResponse xmlns:ns2="http://meFactorial.org/">
<return>120</return>
</ns2:FactResponse>
</S:Body>
</S:Envelope>

Consuming the Web Service

www.vidyarthiplus.com
www.Vidyarthiplus.com

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.meFactorial;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
/**
* @author 4itb21
*/
@WebService(serviceName="FactorialWS")
@Stateless()
public class FactorialWS {
/**
* Web service operation
*/
@WebMethod(operationName = "Fact")
public int Fact(@WebParam(name = "Fact")
int Fact) {
//TODO write your implementation code here:
int i,fact=1;
int number=5;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i; }
System.out.println("Factorial of "+number+" is: "+fact);
return fact;
}}
compile:
run:
Factorial of 5 is: 120
BUILD SUCCESSFUL (total time: 1 second)

Result:
Thus the creation of webservice for Factorial has been verified and executed
successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no. :
Date :
Creating a Web Application

Aim:
To develop a web application.
Procedure:

1. Open a notepad and in file menu open a new document.


2. Using the first tag of html as <html> and to write a document.
3. The next tag is <head> and <title> which used for good presentation with user’s
title.
4. Next in our website comes the <body> tag. Between that type the content, what user
sees.
5. Inside the <body> tag using kinds of tags to enumerate.
For inserting images : <img src="v.3.jpeg" width="250" height="200">
For hyperlink : <a href="url">link text</a>
For inserting forms <form action="demo_form.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
6. After finishing, close all the tags with necessary close tag such as </html>.

Program with Output:


SV.html
<html>
<head>
<title>SV CONSTRUCTION</title>
</head>
<body>
<h1 ALIGN=CENTER><font type="Italic" color="Red">WELCOME TO SV
CONSTRUCTION</font></h1>
<br> </br>
<center><img src="v.3.jpeg" width="250" height="200">
<br> SV CONSTRUCTION </center>
<br> </br>
SV CONSTRUCTIONS
<br></br>
SV construction pvt limited,Erode-638102<br>
Manager Mr.Dharmalingam<br>
Contact:9843025777
<br></br>
<a href="SV construction is a genral contracter and offers superior....html">SV
construction is a genral contracter and offers superior...</a>
<br>

www.vidyarthiplus.com
www.Vidyarthiplus.com

SV construction is a genral contracter and offers superior quality to your buildings and
also guarantee<br>
<br></br>
<a href="SV groups is an industry leader in property development.html">SV groups is an
industry leader in property development</a>
<br>
The sv groups of construction is an industry leader in property development. Our
construction is a successful team to complete more then hundred projects sucessfully.
<br></br>
<a href="SV construction ltd.html">SV construction ltd</a>
<br>
Reference<br> Mr.A.Ajur Ravi
Kumar<br>web:www.svconstruction.ac.in<br>email:ajursvconstruction.gmail.com
<br></br>
<a href="Residential.html">Residential construction model</a>
<br>The workforce development arm of the National Association of the Home
Builders.<br>The Employment and Training Administration has worked with industry
leadrs to develop a comprehensive compentery model for residential construction industry
<br></br>
<a href="Replica.html">Replica Models</a>
<br>The Replica Models are constructed from scaled plans drawn from
photograph.<br>The different scales allow for the large exhibits to fit into the display area.
<br></br>
<a href="Branch.html">Our Branches</a><br>
Our branches are held in many places in Tamilnadu.
</body>
</html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

www.vidyarthiplus.com
www.Vidyarthiplus.com

SV construction is a genral contracter and offers superior....html


<html><body>
SV construction is a genral contracter and offers superior quality to your buildings and
also guarantee.
<br><h2><u><font type="Italic" color="Blue">What we do??</font></u></h2>
Our construction is totally experienced engineers are working together in a team.
They offers most experience workers in all over the projects.
Our consturction complete a work in correct & quick manner.
<br></br>
<h2><u><font type="Italic" color="Blue">Experience</font></u></h2>
Our construction is since 1999.
SV groups are almost done more then Five hundred projects in our carieer in good
manner.<br>
They did following types of projects:<br>
<OL.type='0'>
<li>Classic construction models</li>
<li>Residential construction models</li>
<li>Replica models</li>
<li>Apartment models</li>
<li>Industrial purpose bulidings</li> <br> etc
</body></html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

SV groups is an industry leader in property development.html


<html>
<head>
</head>
<body>
The sv groups of construction is an industry leader in property development. Our
construction is a successful team to complete more then hundred projects sucessfully.
<br></br>
<h2>SV group is anindustry leader in property development.</h2>
<br>
<ol.type='-'>
<li>$26M broadway sqaure feet project</li>
<li>Historic Anna Loune Inn builds new </li>
<li>Villas of the Valley
<li>Visit our residential manage groups</li>
</ol>
</body>
</html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

SV construction pvt. ltd.html


<html>
<head><h1><font color="green"><b>SV construction pvt. ltd.</b></font></h1>
</head>
<body>
<br>
<h3><u>Reference</u></h3><br><h2>Mr.A.Ajur Ravi
Kumar<br>web:www.svconstruction.ac.in<br>email:ajursvconstruction.gmail.com<br></
h2>
<br><h1><font type="Italic" color="brown">Our Core</font></h1>
<h3><ol.type='i'>
<li>Vlues</li>
<li>Integrity</li>
<li>Team work</li>
<li>Excellence</li>
<li>Respect</li>
</ol></h3>
</body></html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

Residential construction model.html


<html>
<head>
<h1><i><font color="red">Residential construction model</font></i></h1>
</head>
<body>
<br>
The workforce development arm of the National Association of the Home
Builders.<br>The Employment and Training Administration has worked with industry
leadrs to develop a comprehensive compentery model for residential construction industry.
<br>
<h2><font color="green"><i>Cockington Green Garden</i></font></h2>
Cockington Green Garden is very specified project in our careeier. This is one of the best
example of our groups.
</body>
</html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

Replica.html
<html>
<head>
<title><h1><i><font color="Brown">The Replica Models </font></i></h1>
</title>
<body>
The Replica Models are constructed from scaled plans drawn from photograph.<br>The
different scales allow for the large exhibits to fit into the display area.
<br></br>
Sign up to
<form method="post" action=" ">
<p><label>Full Name: <input name="Full name" type="text" size="15"
maxlength="25"/></label></p>
<p><label>Email address: <input name="Email address" type="text" size="15"
maxlength="25"/></label></p>
<p><input type="Submit" value="Submit"/>
<input type="reset" value="Cancel"/></p>
</form></body></html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

Branch.html
<html>
<head><Title>Our Branches</title></head>
<Body>
<h1>Our Branches</h1>
<table border="1" width="40%">
<caption><b><font color="rose">Branch Details</font></b></caption>
<thead>
<tr>
<font type="arial" size="6" color="blue">
<th>Address</th>
<th>contact number</th>
</font>
</tr>
</thead>
<tbody>
<tr>
<td>36/38s West street,Shajub road,Ernakulam</td>
<td>8012870616</td>
</tr>

<tr>
<td>47,North Akraharam,Sri rangam,Trichy</td>
<td>9566996531</td>
</tr>

<tr>
<td>South road,Thiruvambur,Kollam</td>
<td>9688738400</td>
</tr>

<tr>
<td>Vellore highways,Chennai-27</td>
<td>9899666531</td>
</tr>

</tbody></table>
</html>

www.vidyarthiplus.com
www.Vidyarthiplus.com

Result:
Thus the creation of web application has been verified and executed successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no. :
Date :
CREATION OF VIRTUAL MACHINE

Aim:
To create a Virtual Machine.

Procedure:

To download a virtual Machine:


1. Go to google and type Oracle virtual Machine.
2. In Oracle VM Virtual Machine link,Click download and select appropriate link for
corresponding system.
Let us take for window & click it, and download with extension pack.

To install
1. Install a software that can be downloaded.
2. For extension
a) Go to file, click on preferences, then click on extensions, the wizard will be open.
b) Click an add symbol, with the file name & click agree to install.

To install a virtual machine into Virtual Machine:


1. Click on New->name as ‘Win7’ and type also will be Microsoft windows and click on next.
2. To select a RAM of virtual machine as 512 MB that can be recommended for windows 7
and click next.
3. To choose a “create a virtual hard drive now” and click create, the wizard will be open.
4. Choose VDI and click next & choose Dynamically located & click next the wizard will be
open.
5. Give the size of virtual machine drives as 20GB and click create & now win 7 will be
created.

To install a win 7 from CD ROM (win 7)


1. By using win 7-CD, select a virtual machine and click on start.
2. Select the hard drive or CD-ROM then click on start then installed.

To install a guest Addition to virtual Machine


1. Go to Drive -> click on “Install guest Additions…”.
2. Go to My Computer -> open CD Drive(D:): Virtual Machine Guest.
3. Select VMachineWindowsAdditions and install that.
4. To start a guest Addition click on finish at the final step.

Copying a folder from original machine to a virtual Machine


1. Go to Device Menu from virtual Machine and Click on shared folders.
2. In that wizard click on Add symbol and from folder path, select a location of a folder and
click ok.
3. And check mark the make permanent & click ok.
4. Right click the my computer in a desktop of VM and select a Map Network drive…
5. Browse the folder we share & click ok from folder & check Machine of Reconnect at logon
and click finish.

To access a USB from Original computer to VM

www.vidyarthiplus.com
www.Vidyarthiplus.com

1. Connect a USB.
2. Go to drive in VM and click USB drives & select a USB device which can be connected.

To share a CD-ROM with VM


1. Click Devices and select CD/DVD Device then click on Host Drive.
2. From MyComputer of VM we can see the CD-ROM

www.vidyarthiplus.com
www.Vidyarthiplus.com

Result:
Thus the creation of Virtual Machine has been verified and executed successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no.:
Date :

Develop new OGSA-compliant Web Service.


Aim:
To Develop new OGSA-compliant Web Service.
Procedure:
 Choose New Project from the main menu.
 Select POM Project from the Maven category.
 Type MavenOSGiCDIProject as the Project name. Click Finish.
 Expand the Project Files node in the Projects window and double-click pom.xml to open
the file in the editor.

The basic POM for the project should be similar to the following.

<?xml version="1.0" encoding="UTF-8"?>


<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>MavenOSGiCDIProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties><project.build.sourceEncoding>UTF-
8</project.build.sourceEncoding>
</properties></project>

 Modify the parent pom.xml to add the following elements. Save your changes.

<?xml version="1.0" encoding="UTF-8"?>


<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>MavenOSGiCDIProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

www.vidyarthiplus.com
www.Vidyarthiplus.com

<dependencyManagement><dependencies><dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency></dependencies></dependencyManagement></project>

Creating the OSGi Bundle Projects

The Maven category in the New Projects wizard includes an OSGi Bundle archetype
for creating OSGi bundle projects. When you create an OSGi bundle project, the generated
POM declares the org.osgi.core JAR as a dependency and specifies the maven-bundle-plugin for
building the project.

Creating the MavenHelloServiceApi Interface Bundle

In this exercise you will use the New Project wizard to create an OSGi bundle project
that will provide a simple interface that will be implemented by other bundles. After you
create the bundle and interface, you will modify the POM to update the dependency on the
org.osgi.core artifact that you specified in the parent POM project.

 Choose File > New Project to open the New Project wizard.
 Choose OSGi Bundle from Maven category. Click Next.
 Type MavenHelloServiceApi for the Project Name.
 Click Browse and select the MavenOSGiCDIProject POM project as the Location. Click
Finish.
 Right-click the MavenHelloServiceApi project node in the Projects window and choose
Properties.
 Select the Sources category in the Project Properties dialog box.
 Set the Source/Binary Format to 1.6 and confirm that the Encoding is UTF-8. Click OK.
 Right-click Source Packages node in the Projects window and choose New > Java Interface.
 Type Hello for the Class Name.
 Select com.mycompany.mavenhelloserviceapi as the Package. Click Finish.
 Add the following sayHello method to the interface (in bold) and save your changes.
 public interface Hello {
 String sayHello(String name);
 }
 Right-click the project node in the Projects window and choose Build.

Creating the MavenHelloServiceImpl Implementation Bundle

 Choose File > New Project to open the New Project wizard.
 Choose OSGi Bundle from the Maven category. Click Next.
 Type MavenHelloServiceImpl for the Project Name.
 Click Browse and select the MavenOSGiCDIProject POM project as the Location (if not
selected). Click Finish.
 Right-click the project node in the Projects window and choose Properties.

www.vidyarthiplus.com
www.Vidyarthiplus.com

 Select the Sources category in the Project Properties dialog box.


 Set the Source/Binary Format to 1.6 and confirm that the Encoding is UTF-8. Click OK.
 Right-click Source Packages node in the Projects window and choose New > Java Class.
 Type HelloImpl for the Class Name.
 Select com.mycompany.mavenhelloserviceimpl as the Package. Click Finish.
 Type the following (in bold) and save your changes.
 public class HelloImpl implements Hello {
public String sayHello(String name) { return "Hello " + name; }}

 Right-click the Dependencies node of MavenHelloServiceImpl in the Projects window and


choose Add Dependency.
 Click the Open Projects tab in the Add Library dialog.
 Select MavenHelloServiceApi OSGi Bundle. Click Add.
 Right-click in the HelloImpl.java class that is open in the editor and choose Fix Imports (Alt-
Shift-I; ⌘-Shift-I on Mac) to add an import statement for
com.mycompany.mavenhelloserviceapi.Hello. Save your changes.
 Expand the com.mycompany.mavenhelloserviceimpl package and double-click Activator.java to
open the file in the editor.

An OSGi bundle does not require a bundle activator class, but you can use the start()
method in the activator class, for example, to initialize services or other resources that are
required by the bundle. In this exercise you will add some lines of code to the class that will
print messages to the Output window. This will make it easier for you to identify when the
bundle starts and stops.

 Modify the start() and stop() methods in the bundle activator class to add the following lines
(in bold).

public class Activator implements BundleActivator {

public void start(BundleContext context) throws Exception {


System.out.println("HelloActivator::start");
context.registerService(Hello.class.getName(), new HelloImpl(), null);
System.out.println("HelloActivator::registration of Hello service successful"); }

public void stop(BundleContext context) throws Exception {


context.ungetService(context.getServiceReference(Hello.class.getName()));
System.out.println("HelloActivator stopped"); } }

 Fix the import statements in Activator.java to import


com.mycompany.mavenhelloserviceapi.Hello. Save your changes.
 Expand the Dependencies node and confirm that the org.osgi.core artifact is listed as a
dependency.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Building and Deploying the OSGi Bundles

 Right-click the MavenOSGiCDIProject node in the Projects window and choose Clean and
Build.
 Start the GlassFish server if not already started.
 Copy the MavenHelloServiceApi-1.0-SNAPSHOT.jar to the
glassfish/domains/domain1/autodeploy/bundles/ directory of your GlassFish installation.
 Right-click the GlassFish server node in the Services window and choose View Domain
Server Log if the server log is not visible in the Output window.
 Repeat the steps to copy the MavenHelloServiceImpl-1.0-SNAPSHOT.jar to the
autodeploy/bundles directory.

OUTPUT:
HelloActivator :: Start
HelloActivator :: registration of Hello Service successful.
HelloActivator :: Stopped.

Result:
Thus the implementation of new OGSA-complaint has been verified and executed
successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.No.:
Date :

Using Apache Axis develop a Grid Service.


Aim:
To use Apache Axis develop a Grid Service
Procedure:
Setup the Development Environment
 First you need to set up the development environment. Following things are needed if
you want to create Web Services using Axis2 and Eclipse IDE.
 Then you have to set the environment variables for Java and Tomcat. There following
variables should be added.
 Now you have to add runtime environment to eclipse. There go to Windows –->
Preferences and Select the Server --> Runtime Environments.
 Then click on the Web Service –-> Axis2 Preferences and browse the top level
directory of Apache Axis2 Binary Distribution.

Creating the Web Service Using Bottom-Up Approach


 First create a new Dynamic Web Project (File --> New –-> Other…) and choose
Web --> Dynamic Web Project.
 Set Apache Tomcat as the Target Runtime and click Modify to install Axis2 Web
Services project facet.
 Select Axis2 Web Services.
 Click OK and then Next. There you can choose folders and click Finish when you
are done.

Create Web Service Class


Right Click on MyFirstWebService in Project Explorer and select New –-> Class and give suitable
package name and class name. I have given com.sencide as package name and FirstWebService as
class name.
package com.sencide;
public class FirstWebService {
public int addTwoNumbers(int firstNumber, int secondNumber){
return firstNumber + secondNumber; }}

 Then, select File --> New –-> Other and choose Web Service.
 Select the FirstWebService class as service implementation and to make sure that the
Configuration is setup correctly click on Server runtime.
 There set the Web Service runtime as Axis2 (Default one is Axis) and click Ok.
 Click Next and make sure Generate a default service.xml file is selected.
 Click Next and Start the Server and after server is started you can Finish if you do
not want to publish the Web service to a test UDDI repository.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Create .aar (Axis Archive) file and Deploying Service


 In your eclipse workspace and go to MyFirstWebService folder and there you can
find our web service inside services folder. Go to that directory using command
prompt and give following command. It will create the FirstWebService.aar file there.
 Then copy the axis2.war file you can find inside the Apache Axis2 WAR Distribution
(You downloaded this at the first step) to the webapps directory of Apache Tomcat.
Now stop the Apache Tomcat server which is running on Eclipse IDE.
 Using command prompt start the Apache Tomcat (Go to bin directory and run the file
startup.bat). Now there will be new directory called axis2 inside the webapps directory. Now
if you go to the http://localhost:8080/axis2/ you can see the home page of Axis2 Web
Application.
 Then click the link Administration and login using username : admin and password : axis2.
There you can see upload service link on top left and there you can upload the created
FirstWebService.aar file. This is equal to manually copping the FirstWebService.aar to
webapps\axis2\WEB-INF\services directory.
 Now when you list the services by going to http://localhost:8080/axis2/services/listServices you
should be able to see our newly added service.

Creating a Web service client


 Select File --> New --> Other… and choose Web Service Client
 Set he newly created Axis2 Web service
(http://localhost:8080/axis2/services/FirstWebService?wsdl) as the Service definition. Then
configure the Server runtime as previously and click finish.
 This will generate two new classes called FirstWebServiceStub.java and
FirstWebServiceCallbackHandler.java. Now we can create test class for client and
use our web service. Create new class called TestClient.java and paste following code.
package com.sencide;
import java.rmi.RemoteException;
import com.sencide.FirstWebServiceStub.AddTwoNumbers;
import com.sencide.FirstWebServiceStub.AddTwoNumbersResponse;
public class TestClient {
public static void main(String[] args) throws RemoteException {
FirstWebServiceStub stub = new FirstWebServiceStub();
AddTwoNumbers atn = new AddTwoNumbers();
atn.setFirstNumber(5);
atn.setSecondNumber(7);
AddTwoNumbersResponse res = stub.addTwoNumbers(atn);
System.out.println(res.get_return()); }
}

OUTPUT:

www.vidyarthiplus.com
www.Vidyarthiplus.com

First number : 5

Second number : 7

Add two number value is : 12

Result:

Thus the implementation of a Grid service using apache axix has been executed
successfully.

Ex.no. :
Date :

www.vidyarthiplus.com
www.Vidyarthiplus.com

IMPLEMENTATION OF ADDING TWO NUMBERS IN C USING VIRTUAL


MACHINE

Aim:
To implement a adding two numbers in c using Virtual Machine.

Procedure:

To download a virtual box:


3. Go to google and type Oracle virtual Machine.
4. In Oracle VM Virtual box link,Click download and select appropriate link
for corresponding system.
Let us take for window & click it, and download with extension pack.

To install
3. Install a software that can be downloaded.
4. For extension
c) Go to file, click on preferences, then click on extensions, the wizard
will be open.
d) Click an add symbol, with the file name & click agree to install.

To install a virtual machine into Virtual box:


6. Click on New->name as ‘Win7’ and type also will be Microsoft windows and
click on next.
7. To select a RAM of virtual machine as 512 MB that can be recommended for
windows 7 and click next.
8. To choose a “create a virtual hard drive now” and click create, the wizard
will be open.
9. Choose VDI and click next & choose Dynamically located & click next the
wizard will be open.
10. Give the size of virtual machine drives as 20GB and click create & now win 7
will be created.

To install a win 7 from CD ROM (win 7)


3. By using win 7-CD, select a virtual machine and click on start.
4. Select the hard drive or CD-ROM then click on start then installed.

To install a guest Addition to virtual Machine


5. Go to Drive -> click on “Install guest Additions…”.
6. Go to My Computer -> open CD Drive(D:): Virtual box Guest.
7. Select VBoxWindowsAdditions and install that.
8. To start a guest Addition click on finish at the final step.

www.vidyarthiplus.com
www.Vidyarthiplus.com

To implement a addition program in virtual machine


To write a program in text-editor:
1. From the desktop of virtual machine open the “search your computer and
online search”.
2. Inside that open “Text Editor”.
3. Write a c program to add a two numbers and display the result.
4. Save the program with extension “add.c”.

To compile a c program:
1. Go to “Terminal” which is located in a desktop of virtual machine.
2. To run a program as “gcc add.c”.
3. To compile a program as “./a.out”.
4. Output will be Display in virtual machine screen.

www.vidyarthiplus.com
www.Vidyarthiplus.com

www.vidyarthiplus.com
www.Vidyarthiplus.com

Result:
Thus the implementation of adding two numbers in c by using virtual
machine has been verified and executed successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no. :
Date :

IMPLEMENTATION OF READING THE CONTENT FROM THE FILE

Aim:

To write a program by using an API’s (file concept-read/write) of hadoop

Procedure:

Step1.1: To start the hduser

ksriet@ksrietcsevb:~$ su hduser

Password: (type hduser)

Step1.2: To Change the directory

hduser@ksrietcsevb:/home/ksriet$ cd /usr/local/hadoop/sbin

prerequirement :

 create a text file called bala.txt with some line in home directory
 create hduser in home directory
 save filestream.java in hduser
 create fscat directory in hduser directory
 create filestream.java in hduser folder(directory create newly in home directory)

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ start all.sh

mkdir /home/hduser/fscat

Step2:Compiling the filestream.java

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ sudo /usr/lib/jvm/java8oracle/bin/javac


classpath

/home/hduser/hadoopcore1.2.1.jar d /home/hduser/fscat
/home/hduser/filestream.java

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ ls /home/hduser/fscat

www.vidyarthiplus.com
www.Vidyarthiplus.com

fstream.class

Step3:Creating jar file for HadoopFScat3.java:

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ jar cvf /home/hduser/fscat.jar C


/home/hduser/fscat/

Step4.Executing Jar File For Hadoopfscat.Java

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop jar /home/hduser/fscat.jar


HadoopFScat

/user/input/bala.txt

Step5:Display the ouput of bala.txt content

Program:

import java.io.InputStream;

import java.net.URI;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.FileSystem;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.IOUtils;

public class filestream {

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

String uri = args[0];

Configuration conf = new Configuration();

FileSystem fileSystem = FileSystem.get(URI.create(uri), conf);

InputStream inputStream = null;

try{

inputStream = fileSystem.open(new Path(uri));

www.vidyarthiplus.com
www.Vidyarthiplus.com

IOUtils.copyBytes(inputStream, System.out, 4096, false);

} finally{

IOUtils.closeStream(inputStream);

}}}

INPUT:
(itvcet.txt)

All the best

OUTPUT:

Display the content of itvcet.txt

All the best

Result:

Thus the implementation of reading the content from the file has been executed
successfully.

Ex.No. :
Date :

www.vidyarthiplus.com
www.Vidyarthiplus.com

Implementation of Map and Resuce Tasks

Aim:
To Write a Word count program that demonstrate the use of Map and Reduce
tasks.

Procedure:
Go to Oracle virtual Box (-> file-> import->select location hadoop ova file and
import)

ksriet@ksrietcsevb:~$ su hduser

Password: hduser

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

Compile

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ sudo
/usr/lib/jvm/java-8-oracle/bin/javac -classpath/home/hduser/hadoop-core-1.2.1.jar -d
/home/hduser/wc /home/hduser/WordCount.java[sudo] password for hduser:

Creating Jar File

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ jar -cvf /home/hduser/wc.jar -C


/home/hduser/wc/ .

Copy File(Bala.Txt) To User /Input

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop fs -put /home/hduser/bala.txt


/user/input

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop fs -ls /user

Found 2 items

drwxr-xr-x - hduser supergroup 0 2016-09-20 13:51 /user/input

drwxr-xr-x - hduser supergroup 0 2016-09-20 15:46 /user/output

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop fs -cat /user/input/it.txt

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

16/09/20 17:18:48 WARN util.NativeCodeLoader: Unable to load native-hadoop library for


your

www.vidyarthiplus.com
www.Vidyarthiplus.com

platform... using builtin-java classes where applicable

“cloud computing and grid computing are newer concepts compared to other large computing
solutions”
Execute

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop jar /home/hduser/wc.jar WordCount


/user/input

/user/output

PROGRAM:

WordCount.java

import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class WordCount {
public static class TokenizerMapper
extends Mapper<Object, Text, Text, IntWritable>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
}}}

public static class IntSumReducer


extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,

www.vidyarthiplus.com
www.Vidyarthiplus.com

Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}}

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


Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "word count");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}}

OUTPUT:

Check For Output

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop fs -ls /user/output

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

16/09/14 17:22:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for


your

platform... using builtin-java classes where applicable

Found 2 items

-rw-r--r-- 1 hduser supergroup 0 2016-09-14 15:46 /user/output/_SUCCESS

-rw-r--r-- 1 hduser supergroup 174 2016-09-14 15:46 /user/output/part-r-00000

Check The Output

www.vidyarthiplus.com
www.Vidyarthiplus.com

hduser@ksrietcsevb:/usr/local/hadoop/sbin$ hadoop fs -cat /user/output/*

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

16/09/14 17:24:07 WARN util.NativeCodeLoader: Unable to load native-hadoop library for


your

platform... using builtin-java classes where applicable

cloud 1
computing 3
and 1
grid 1
are 1
newer 1
concepts 1
compared 1
to 1
other 1
large 1
solutions 1

RESULT:
Thus the implementation of a Word count program that demonstrate the use of Map and
Reduce tasks has been verified and executed successfully.

Ex.no. :
Date :

www.vidyarthiplus.com
www.Vidyarthiplus.com

Develop secured applications using basic security mechanisms available in Globus


Toolkit.
Aim:
To develop secured applications using basic security mechanisms available in Globus
Toolkit.
Procedure:
nsp@nspublin:~$ sudo grid-ca-create -noint

Output

Result:

Thus the implementation of secured applications using basic security


mechanisms available in globus toolkit .

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no. :
Date :
Implementation of virtual machine migration based on the certain condition from
one node to the other
Aim:
To show the virtual machine migration based on the certain condition from one
node to the other.
Procedure:
Existing images can be cloned to a new one. This is useful to make a backup of an
Image before you modify it, or to get a private persistent copy of an image shared by
other user.
To clone an image, execute
$ oneimage clone Ubuntu new_image
Listing Available Images
You can use the oneimage list command to check the available images in the
repository.
$ oneimage list

ID USER GROUP NAME DATASTORE SIZE TYPE PER STAT RVMS

0 oneuser1 users Ubuntu default 8M OS No rdy 0


To get complete information about an image, use oneimage show, or list images
continuously with oneimage top.

Result:
Thus the Implementation of virtual machine migration based on the certain
condition from one node to the other has been verified and executed successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no. :
Date :

Implementation of Mount the one node Hadoop cluster using FUSE.


Aim:
To Mount the one node Hadoop cluster using FUSE
Procedure:
However, one can leverage FUSE to write a userland application that exposes
HDFS via a traditional filesystem interface. fuse-dfs is one such FUSE-based
application which allows you to mount HDFS as if it were a traditional Linux
filesystem. If you would like to mount HDFS on Linux, you can install fuse-dfs,
along with FUSE as follows:
wget http://archive.cloudera.com/one-click-install/maverick/cdh3-
repository_1.0_all.deb
sudo dpkg -i cdh3-repository_1.0_all.deb
sudo apt-get update
sudo apt-get install hadoop-0.20-fuse
Once fuse-dfs is installed, go ahead and mount HDFS using FUSE as follows.
Sudo hadoop-fuse-dfs dfs://<name_node_hostname>:<namenode_port>
<mount_point>
Once HDFS has been mounted at <mount_point>, you can use most of the
traditional filesystem operations (e.g., cp, rm, cat, mv, mkdir, rmdir, more, scp).
However, random write operations such as rsync, and permission related operations
such as chmod, chown are not supported in FUSE-mounted HDFS.

Result:
Thus the Implementation of Mount the one node Hadoop cluster using FUSE
has been verified and executed successfully.

www.vidyarthiplus.com
www.Vidyarthiplus.com

Ex.No. :
Date :

INSTALL AND INTRACT WITH A STORAGE CONTROLLER-USB

Aim:
To write a procedure for installing a storage controller and interacting with it.

Procedure:

VirtualBox Configuration:

1. Check “Enable USB Controller” check box. If the device is USB 2.0 complaint check
“Enable USB 2.0 (EHCI) Controller check box that is Basic USB Configuration
Without Any Filters
2. Click on “Add Filter From Device”.This will bring the pop-up menu with all USB
devices connected to the host.
3. In the pop-up menu scroll down the device you want to access and click on it. Filter
is added for selected device.

USB Driver Installation:

1. As soon as you start the virtual machine, Windows will pop-up a Found New
Hardware Wizard.
2. Select “No, Not this time” radio button and click on next, this time wizard will ask
you to choose between installation method.
3. Select “Install the software automatically” and click on next, This will start the driver
installation process.
4. You will get the successful completion dialog box for the driver installation, close that
dialog box and your virtual machine will continue with booting operation. You might
have to do this again if you connect the same device to some other USB port on the
computer.

Verification Under Guest OS:

1. From this point onwards In ubuntu (Linux) specific information as my guest OS is


Ubuntu.
2. Ubuntu will find the new USB Flash drive and mount it automatically.
3. Open the console and type lsusb, this command will give you a list of available USB
devices

www.vidyarthiplus.com
www.Vidyarthiplus.com

Result:

Thus the installation of Storage Controller and interacting with that has been done
successfully.

www.vidyarthiplus.com

Anda mungkin juga menyukai