Remote Procedure Calls (RPC) Concept
Remote Procedure Calls comes to play when we want process that are residing in different systems connected with each other.
One process residing in a system wants communicate to another process which is residing physically in another system that connected via network. RPC protocol help on program to request a service from a program located in another computer on a network.
RPC Concept
In the client machine, client invokes a client stub procedure, by passing parameters. This call is a local procedure call.
The client stub marshalls the parameters into a message. Marshalling includes converting the pre presentation of the parameters into a standard format and copying each parameter into message and makes a system call to send messages.
The messages from the client machine sends to the remote server machine.
In the remote server-side message passes to the server stub, which demarshalls the parameter received.
After server procedure finished, it returns to the server stub, which marshalls the return values into a message back to client.
Client stub unmarshalls and execute returns to caller.
For example –
Requirement — Create a web service to find whether given number is prime or not and develop a client which consumes it using java.
Server-side Implementation
1- Service endpoint interface
This is a java interface. This declare the method that client invokes.
2- Server endpoint implementation
3- Web service publisher class
In this class we are calling create method of Endpoint class for creating the endpoint for the given implementation object. And also calling publish method of Endpoint class which is used to publish the endpoint
So now the service is deployed at http://localhost:8879/rpc/primeNumber
For wsdl file response, browse http://localhost:8879/rpc/primeNumber?wsdl
It gives the XML file contains all server URI and service name which are implemented as server in order to pass arguments in Qname.
Client-side Implementation
1- Web service client and implementation
User client interface in order to do marshalling and demarshalling.
The out put is like this.
Thank You…!