RPC — Remote Procedure Call
RPC is used to client server based applications and it is a powerful for constructing distributed. Without having to understand the network’s details RPC can use to request a service from a program located in another computer. The service providing program working as a server and the requesting program working as a client.
RPC Working Flow
The client has a request message. Then that message RPC translate and send to the server. This request message can be a procedural or a function call to a remote server. After the server receive the message request server send the response back to the client. While the server is processing the call client is blocked.
- Client is called to Client Stub.
- Client Stub makes system calls to send message to the server.
- Using client’s operating system the message is sent client to server.
- The message is passed to the server stub by the server operating system.
- The parameters what set by the client stub are removed from the message.
- Finally, the server procedure is called.
Practical example for RPC
Let’s see a simple example for RPC.
In this scenario client send some String HelloWorld value and sever display that String.
Server Side Code
RPCHelloWorld.java
RPCHelloWorldImpl.java
RPCHelloWorldPublisher.java
Then run Publisher code . After running the Publisher code we can get XML output when browse below URL.
http://localhost:7779/RPC/hello?wsdl
Client Side Code
RPCHelloWorldClient.java
Then execute this part and output will be like this.