0% found this document useful (0 votes)
8 views5 pages

Practical 1

Webservice2

Uploaded by

renuseom12
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)
8 views5 pages

Practical 1

Webservice2

Uploaded by

renuseom12
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/ 5

Practical 1

Name = om Bajirao renuse


Seat no. 31011022019
Class = ty.it.honours
Subject = web services
Aim = Remote Method Invocation
Code:-
Client.java
import java.rmi.*;

public class Client


{
public static void main(String args[])
{
try
{
ServerInterface ob2= (ServerInterface)Naming.lookup("Calc");
System.out.println("The first number is:"+args[0]);
double d1=Double.valueOf(args[0]).doubleValue();
System.out.println("The second number is:"+args[1]);
double d2=Double.valueOf(args[0]).doubleValue();
System.out.println("The number is :"+ ob2.add(d1,d2));
}
catch(Exception e)
{
System.out.println("exception" +e);
}
}
}
SeverInterface.java
import java.rmi.*;

public interface ServerInterface extends Remote


{
double add (double d1,double d2) throws RemoteException;
}

ServerImple.java
import java.rmi.*;
import java.rmi.server.*;

public class ServerImple extends UnicastRemoteObject implements ServerInterface


{
public ServerImple() throws RemoteException
{

}
public double add (double d1,double d2) throws RemoteException
{
return d1+d2;
}
}
MainServerProg.java
import java.net.*;
import java.rmi.*;

public class MainServerProg


{
public static void main(String[] args)
{
try
{
ServerImple ob1=new ServerImple();
Naming.rebind("Calc", ob1);
}
catch (Exception e)
{
System.out.println("Ecxception"+e);
}
}
}
Output:-

You might also like