What is a gRPC API and how does it work?

Google Trends shows increasing interest in gRPC since its release in 2015.

Figure 1: According to Google Trends, there has been a growing interest in gRPC since it's release in 2015

Figure 2: RPC makes it possible for a computer to share a procedure (function) with other computers

Figure 2: RPC makes it possible for a computer to share a procedure (function) with other computers

Figure 3: SAP's Remote Function Calls (RFC) is a variant of the RPC architecture style

Figure 3: SAP's Remote Function Calls (RFC) is a variant of the RPC architecture style

Figure 4: Java Remote Method Invocation makes it possible to access functions on a remote server

Figure 4: Java Remote Method Invocation makes it possible to access functions on a Remote server

Listing 3: The Java RMI client code that calls a remote method

Listing 3: The Java RMI client code that calls a remote method

ProgrammableWeb interactive tutorial on Katacoda
ProgrammableWeb's interactive lessons about XML-RPC on Katcoda
Listing 4: A simple call to the ping method on the demonstration XML-RPC API server

Listing 4: A simple call to the ping method on the demonstration XML-RPC API server

Table 1: The XML-RPC scalar types

Tag Type Example
i4 or int four-byte signed integer -22
boolean 0 (false) or 1 (true) 1
string string I like ice cream
double double-precision signed floating point number -22.214
dateTime.iso8601 date/time 19980717T14:08:55
base64 base64-encoded binary eW91IGNhbid0IHJlYWQgdGhpcyE=
Listing 5: A response to the ping method on the demonstration XML-RPC API server

Listing 5: A response to the ping method on the demonstration XML-RPC API server

Listing 6: A call to a XML-RPC procedure, add, that take an array of integers to sum

Listing 6: A call to a XML-RPC procedure, add, that take an array of integers to sum

Listing 7: The response from a XML-RPC procedure, add, that summed up an array of integers

Listing 7: The response from a XML-RPC procedure, add, that summed up an array of integers

Listing 8: A call to the custom procedure, chatter, using a structure with two named parameters.

Listing 8: A call to a custom procedure, chatter, that uses named values in a structure that includes two named parameters

XML-RPC API procedure, chatter responds with an array of values, each of which contains a struct

Listing 9: XML-RPC API procedure, chatter responds with an array of values, each of which contains a struct

Figure 5: The basic structure of a SOAP message

Figure 5: The basic structure of a SOAP message

Table 2

Element Description
Envelope Describes the XML document as a SOAP message.
Header Contains header information.
Body Information relevant to the request or response being made
Fault Contains information about errors that occurred during message processing.
Listing 10: A web service request written in SOAP

Listing 10: A web service request written in SOAP

Listing 11: A web service response written in SOAP

Listing 11: A web service response written in SOAP

Table 3: The number of bits required to transmit the name, John James according to first name and last name.

Example Word Count Bit count
Listing 4: HTML 151 1208
Listing 5: XML 96 768
Listing 6: JSON 47 376
Figure 6: The gRPC API schema is defined in a .proto file shared by both client and server.

Figure 6: The schema that describes the gRPC API is defined in a .proto file that is shared by both client and server

Listing 15: The .proto file that describes a simple gRPC API

Listing 15: The .proto file that describes a simple gRPC API

Figure 7: Binary encoding under Protocol Buffers uses index numbers to segment and identify fields

Figure 7: Binary encoding under Protocol Buffers uses index numbers to segment and identify fields

Using BloomRPC as a gRPC client app, the Simple Service Add function sums numbers from a submitted array.

Figure 8: The Simple Service Add function sums up all the numbers in the submitted array using BloomRPC as a gRPC client application

Figure 9: The Simple Service Divide function divides numbers in the array by their positions.

Figure 9: The Simple Service Divide function divides the numbers in the submitted array according to each number's position in the array

Figure 10: The Simple Server function, Chatter returns ChatterResponse message in a stream

Figure 10: The Simple Server function, Chatter returns ChatterResponse message in a stream

+

Esta página está disponible en español

Ver en español