Distributed and Cloud Computing
Hello World System Using Java RPC
Remote Procedure Call is used for building the distributed client-server based applications. It provides a communication mechanism for client machines to call procedures in the server machines which are running separately and in various environments.
In here, we are going to implement a simple hello world application using Java RPC. For that, 3 files are implement as the server and one file implements as client. The strategy is the client is calling a function in the server and server response to the client.
The three files which are implemented as server is:
HelloWorld –Web Service Interface
HelloWorldImpl — Implementation of HelloWorld service
HelloWorldPublisher — End Point Publisher
The file which is implemented as client:
HelloWorldClient
So, we are using Request-Reply Communication. Let’s see how this application related with it. Here I provide a rough architecture of Request-Reply Communication.
As the client we doOperation as call to a function (getHelloWorldAsString())in the server. So, Server get the request from the endpoint and Server response (sendReply) to the client. A publisher publishes the endpoint to the client.
Ok, let’s get stared…..
Here the file structure in the IDE (In here, I used IntelliJ)
First implements HelloWorld.java as an Interface
HelloWorld.java
HelloWorld.java fille is created as a web service that piece of code which is available in the internet. So, the interface has the method named getHelloworldAsString(). @WebMethod is to expose the method as public operation in the web service.
@SOAPBinding used to specify the binding of the properties defined in the web service.
HelloWorldImpl.java
The method in the interface is implemented in the HelloworldImpl.java
HelloWorldPublisher.java
Publisher deploys the URL “http://localhost:7771/WS/hello” when it is run. It contains the document tree. The WSDL xml file is generated after publisher is run.
HelloWorldClient.java
The URL which is the endpoint that provides from the service. Client call the getHelloWorldAsString() and pass a string value.
Here the XML file, when copy and paste the url in the HelloWorldClient.java
Finally, when run the HelloWorldClient here the output