RPC (JSON-RPC, XML-RPC)

API - Application Programming Interface

2 min read

Published Sep 24 2025


8
0
0
0

API

RPC (Remote Procedure Call) is a communication method where a program calls a procedure (function) on a remote system as if it were local. The client sends a request to the server, which executes the procedure and returns a response.

RPC abstracts away the details of network communication, making remote calls look like local function calls.





Types of RPC

XML-RPC:

  • Uses XML to encode requests and responses.
  • Typically sent over HTTP.

Example request:

<?xml version="1.0"?>
<methodCall>
  <methodName>getUser</methodName>
  <params>
    <param><value><int>123</int></value></param>
  </params>
</methodCall>

Example response:

<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member><name>id</name><value><int>123</int></value></member>
          <member><name>name</name><value><string>Alice</string></value></member>
        </struct>
      </value>
    </param>
  </params>
</methodResponse>


SON-RPC

  • Uses JSON for request/response.
  • Lightweight and easier to parse than XML.

Example request:

{
  "jsonrpc": "2.0",
  "method": "getUser",
  "params": { "id": 123 },
  "id": 1
}

Example response:

{
  "jsonrpc": "2.0",
  "result": { "id": 123, "name": "Alice" },
  "id": 1
}




Key Features

  • Method-centric → Call a function/method rather than accessing a resource.
  • Synchronous → Client waits for server response (though async variants exist).
  • Transport agnostic → Usually HTTP, but can use TCP or other protocols.
  • Lightweight (JSON-RPC) vs Verbose (XML-RPC).



Advantages

  • Simple model — “call a function remotely.”
  • Easy to implement for small services.
  • JSON-RPC is lightweight, readable, and fast for modern web apps.



Disadvantages

  • Less standardised than SOAP or REST.
  • Error handling can be inconsistent.
  • Not ideal for complex enterprise workflows.
  • Limited tooling and ecosystem compared to REST/GraphQL/gRPC.



Use Cases

  • Internal services where simplicity is enough.
  • Lightweight web services for data retrieval or small operations.
  • Legacy systems using XML-RPC.
  • Modern microservices or WebSocket-based services can use JSON-RPC

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact