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.