Remote Procedure Calls (RPC) Concept….

Mohamed Thasneem
2 min readJul 25, 2020

--

Remote Procedure Call (RPC) may be a message-passing programming technology developed by Sun Microsystems and extended by the Open Software Foundation (OSF) that permits an application to execute procedures and interact with services on a foreign computer on the network.

Step 1) The client, the client stub, and one instance of RPC run time execute on the client machine.

Step 2) A client starts a client stub process by passing parameters within the usual way. The client stub stores within the client’s own address space. It also asks the local RPC Runtime to remit to the server stub.

Step 3) during this stage, RPC accessed by the user by making regular Local Procedural Cal. RPC Runtime manages the transmission of messages between the network across client and server. It also performs the work of retransmission, acknowledgement, routing, and encryption.

Step 4) After completing the server procedure, it returns to the server stub, which packs (marshalls) the return values into a message. The server stub then sends a message back to the transport layer.

Step 5) during this step, the transport layer sends back the result message to the client transport layer, which returns back a message to the client stub.

Step 6) during this stage, the client stub demarshalls (unpack) the return parameters, within the resulting packet, and therefore the execution process returns to the caller.

A Java Example For RPC

Server-side Implementation

  1. Create an interface ( Employee interface )
package com.thasneem.rpc;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public interface EmployeeInterface {
@WebMethod String getEmployeeName(String employeeName);
}

2. Implement the Interface (Employee Implementation )

package com.thasneem.rpc;

import javax.jws.WebService;
@WebService(endpointInterface = "com.thasneem.rpc.EmployeeInterface")
public class EmployeeImpl implements EmployeeInterface{
@Override
public String getEmployeeName(String employeeName) {
return "Employee Name : " + employeeName;
}
}

3. Publisher

package com.thasneem.rpc;

import javax.xml.ws.Endpoint;
public class RpcApplication {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/employee", new EmployeeImpl());
}
}

Client-side Implementation

Client

package com.thasneem.rpc;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class Client {
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:8080/employee?wsdl");
QName qname = new QName("http://rpc.thasneem.com/", "EmployeeImplService");
Service service = Service.create(url, qname);
EmployeeInterface employee = service.getPort(EmployeeInterface.class);
System.out.println(employee.getEmployeeName("Thasneem"));
}
}

Run the Publisher and the Client

Output

Thank you! …

--

--

No responses yet