JAVA RPC (Remote Procedure Call)

Paul issack minoltan
3 min readJul 18, 2020

--

RPC (Remote Procedure Call) is the protocol that one program request a service from an another computer(program located computer) on a network without knowing the details of network.

In distributed system, the RPC is the two processes may be on the same system, or they may be on different systems with a network connecting them.

RPC is used to request other processes on the remote systems like a local system. A procedure call is also sometimes known as a function call or a subroutine call.

RPC is the client server architecture. The requesting system is client and the service providing program is the server.

RPC is a synchronous operation requiring the requesting program to be suspended until the results of the remote procedure are returned.

However, the use of lightweight processes or threads that share the same address space enables multiple RPC to be performed concurrently.

During an RPC, the following steps take place:

  1. The calling stub is suspended when parameters are transferred across the network to the stub where the procedure is to execute. The call is a local procedure call with parameters pushed onto the stack in the normal way.
  2. The client stub packs the procedure parameters into a message and makes a system call to send the message. The packing of the procedure parameters is called marshalling.
  3. The client’s local OS sends the message from the client machine to the remote server machine.
  4. The server OS passes the incoming packets to the server stub.
  5. The server stub unpacks the parameters called unmarshalling
  6. When the server procedure is finished, it returns to the server stub, which marshals the return values into a message. The server stub then hands the message to the transport layer.
  7. The transport layer sends the resulting message back to the client transport layer, which hands the message back to the client stub.
  8. The client stub unmarshalls the return parameters, and execution returns to the caller.

Advantages of Remote Procedure Call

Can be used in a distributed environment and local environment.

supports thread-oriented models and process-oriented.

Hides the internal message-passing mechanism from the user.

Omits many of the protocol layers to improve performance.

Helps clients to communicate with servers , use of procedure calls in high-level languages.

Disadvantages of Remote Procedure Call

There is no uniform standard for RPC -It can be implemented in a variety of ways.

Highly vulnerable to failure -It involves a communication system, another machine and another process.

Implementation

There are 4 files. The first 3 files are created for server side and 1 application for client side.

Server Side

  1. HelloWorld.java
  • import javax.jws.WebMethod;
  • import javax.jws.WebService;
  • import javax.jws.soap.SOAPBinding;
  • import javax.jws.soap.SOAPBinding.Style;

In this Interface we declare all the methods with required parameters to the web service

2. HelloWorldImpl.java

import javax.jws.WebService;

3. Publisher.java

import javax.xml.ws.Endpoint;

Client Side

4. HelloWorldClient.java

  • import java.net.URL;
  • import javax.xml.namespace.QName;
  • import javax.xml.ws.Service;

Visit the following git repository to see the project file https://github.com/minoltan/rpc/tree/master/SE-2015-021/RPC

JAX-WS API is inbuilt in JDK, so we don’t need to add any extra jar file.

The End..!

--

--

Paul issack minoltan
Paul issack minoltan

Written by Paul issack minoltan

I am a Professional Software Engineer

No responses yet