0

I am having a hard time understanding RPC in terms of the implementation. Several articles that I have read on RPC, I have seen following examples related to RPC:

Example: A RPC api

GET /readStudent?studentid=123

Example: A RPC call

POST /student HTTP/1.1
HOST: api.demo.com
Content-Type: application/json

{"name": "John Doe"}

As far as I have read and understood, RPC allows a client application to directly call methods on a server application on a different machine as if it was a local object.

So, what is the above examples all about ? Why are we making api calls instead of invoking methods ?

I am assuming that in these RPC examples above, the URLs might be pointing to public methods and the method arguments are passed here in the query string or body.

And if that is the case, why can't I simply use REST then ? Why make an effort of exposing public methods(whose actual implementation must be elsewhere according to RPC principles) through HTTP api ?

I am also confused about what is the actual RPC way and which way should be preferred.

oblivion
  • 4,595
  • 1
  • 27
  • 50

1 Answers1

0

Your examples could indicate how one RPC implementation transports requests to a distinct process. But there should be a translation layer that lets a client simply call methods/functions/procedures, like readStudent(123) and createStudent("John Doe"). Often there is also a corresponding server-side layer that lets the application code implement only those methods/functions/procedures (and not the details of the JSON/HTTP or other transport). These translation (or "marshalling") layers are often machine-generated from an application-specific interface specification, to avoid tedious manual coding of the translation boilerplate. Such interface specification is written in an Interface Definition Language (IDL).

REST imposes some conventional semantics that method calls may not honor. And it does not necessarily offer a translation layer to give the illusion of application-specific method calls.

asynchronos
  • 470
  • 2
  • 14