Thomas Bayer presents a complete example of an introduction to XML-RPC functionality in an application-related article at https://www.oio.de/public/xml/xml-rpc.htm
The following notes should not be missing in this book chapter: The gb. xml. rpc component uses its own internal mini HTTP server to provide XML-RPC services. The component is not designed to use the internal mini HTTP server in the same way as PHP web services, for example. RPC is therefore not a web service in the usual sense - but a service provided by a local HTTP server. An XML RPC server is an HTTP server, just like Apache2 or Lighttpd. Unlike the aforementioned servers, XMLRPC servers do not normally run on port 80 and do not deliver Web pages.
The component gb.xml.rpc has the classes RpcServer, RpcClient, RpcFunction, RpcArray, RpcStruct and RpcType. The classes RpcServer and RpcClient are described in separate chapters. The relevant projects are also presented there.
The client request (Request) and the server response (Response) each contain a multiline XML section containing the arguments (Request) or the function value (Response). For the project with the arguments summand1=12 and summand2=8 and the function value summe = 20, the XML sections look like this:
Request extract:
POST /RPC HTTP/1.1 ... Content-Length: 230 Content-Type: text/xml <?xml version="1.0"?> <methodCall> <methodName>add2integer</methodName> <params> <param> <value><int>12</int></value> </param> <param> <value><int>8</int></value> </param> </params> </methodCall>
Response neck:
... <?xml version="1.0"?> <methodResponse> <params> <param> <value> <int>20</int> </value> </param> </params> </methodResponse>
You can create an object of the class RpcFunction (gb. xml. rpc):
Dim hRpcFunction As RpcFunction hRpcFunction = New RpcFunction(Name As String, DataTypes As Integer[], Ret As Integer)
You can use the class RpcFunction like a read-only array:
Dim hRpcFunction As RpcFunction Dim anInteger As Integer anInteger = hRpcFunction [ Index As Integer ]
The following table contains the properties of the class RpcFunction:
Property | Data type | Description |
---|---|---|
Count | Integer | Specifies the number of arguments of the RPC function. |
Help | String | Sets the help text for the RPC function or returns the help text. |
MethodName | String | Returns the name of the method. |
ReturnType | Integer | Returns the data type of the function value → chapter 27.5.0.6.2 |
Table 27.5.0.3.1: Properties of class RpcFunction
You can create an object of the class RpcArray (gb.xml.rpc):
Dim hRpcArray As RpcArray hRpcArray = New RpcArray()
You can use the class RpcArray like a read-write array:
Reading:
Dim hRpcArray As RpcArray Dim aVariant As Variant aVariant = hRpcArray [ Index As Integer ]
Writing:
Dim hRpcArray As RpcArray Dim aVariant As Variant hRpcArray [ Index As Integer ] = aVariant
The RpcArray class has only the read-only Count property of the Integer data type, which returns the number of elements in the array.
Here you will find an overview of selected methods of the class RpcArray:
Method | Return type | Description |
---|---|---|
Add (Value As Variant, DataType As Integer) | ~ | Inserts an element into the RPC array. |
Clear () | ~ | All elements in the RPC array are deleted. |
Pop () | Variant | Removes the last element of an RPC array and returns this element as a Variant function value. If the original RPC array is empty, an error is triggered. |
Push (Value As Variant, DataType As Integer) | ~ | Inserts an element at the end of an RPC array. |
Remove (Index As Integer) | ~ | Deletes the element with the specified index in the RPC array. |
Reverse () | RpcArray | The order of the array elements is inverted - the array elements E0… En are rearranged to En…E0 . The inverted RPC array is returned as a function value. |
Table 27.5.0.4.1: Selected methods of the class RpcArray
You can create an object of the class RpcStruct (gb. xml. rpc):
Dim hRpcStruct As RpcStruct hRpcStruct = New RpcStruct()
The class RpcStruct has only the read-only property Count of the data type Integer, which returns the number of fields in the structure.
Here you will find an overview of the seven methods of the class RpcStruct:
Method | Return type | Description |
---|---|---|
Add (Name As String, Value As Variant, DataType As Integer) | ~ | A field with the specified field name, field value, and specification of the appropriate data type is added to a structure. |
Clear () | ~ | All fields in the structure are deleted. |
Copy () | RpcStruct | A structure is copied 1:1 and returned as a function value. |
Key (Index As Integer) | String | The key for the given field index is returned as a function value. |
Value (Index As Integer) | Variant | The field value for the given field index is returned as a function value. |
Remove (Index As Integer) | ~ | Deletes the element with the specified index in the structure. |
Reverse () | RpcStruct | The order of the elements is inverted - the structure elements E0… En are reordered to En…E0: The inverted structure is returned as a function value. |
DataType (Index As Integer) | Integer | Defines the data type of a field in the structure or returns its data type. |
Table 27.5.0.5.1: Methods of the class RpcStruct
The class RpcType (gb.xml.rpc) is static and contains 2 (static) conversion methods and nine constants. The classes RpcType and XmlRpc have the same methods and constants and can therefore be used synonymously.
Here you find an overview of the two methods of the class RpcType:
Method | Return type | Description |
---|---|---|
Function ToString (type As Integer) | String | Converts a constant integer value into its (string) description. |
Function ToType (type As String) | Integer | Converts a (string) description into its constant value. |
Table 27.5.0.6.1: Methods of the class RpcType