Remote Procedure Calls
First let’s understand the concept of RPC.
Simply we use Remote Procedure Calls to communicate with other components in a server. A component can request a service from another component in the network by a remote procedure Call. RPC use in distributed and client server model based applications. Components can be implemented in a single system or with different systems which are networked. RCP is a protocol which helps a system to communicate with remote systems as a local system component.
Let’s dig more in to this concept.
How this process happens?
Client (Caller)
First a client sends a local call to the client stub which invoked with the relevant parameters. Then the clients stub packs the parameters, which is known as marshalling in to a message. (You can refer my blog on External data representation and Marshalling to know about marshalling and unmarshalling). Then the request message which contains remote proceduer’s parameters from the client machine is sent to the remote server machine.
Server (Callee)
In the remote server-side message passes to the server stub, which demarshalls the parameters received. Then the server starts procedure execution. After the execution reply message is been sent to the server stub. There also it marshalls the reply message with values and sent it to the client.
We will understand this through an example.
Think we need to print numbers lesser than 10.
Server-side Implementation
printnumbers.java class
printnumebrsImpl.java class
printnumbersPublisher.java
http://localhost:7779/ws/hello
After running the publisher code, you can see the generated WSDL file by visiting the URL:
http://localhost:7779/ws/hello?wsdl
Client-side Implementation
printnumbersClient.java
Output
Thank You!