<commit_before># XmlRpcMessageService

A service for creating [XML-RPC](http://xmlrpc.scripting.com/spec.html)'s method call XML from a simple JavaScript object, and parsing method response XML to a JavaScript object.
This service also provides a method for posting method calls to a URL and parse the response.
For example, the following is a login method to [OpenSubtitles.org](http://www.opensubtitles.org) service:
```javascript
function login() {
  Logger.log("Logging in...");
  var methodCall = {
    methodName : "LogIn",
    params : [ "", "", "en", "OS Test User Agent" ]
  };
  var url = "http://api.opensubtitles.org/xml-rpc";
  var methodResponse;
  XmlRpcMessageService.execMethodCall(url, methodCall, function(mr) { methodResponse = mr; });
  var token = methodResponse.params[0].token;
  Logger.log('Logged in. Token: ' + token);
  return token;
}
```

A more simple API can be achieved using service binding. In this option, a service object is created with binding to a server URL. The service object then has native JavaScript functions for each remote server method. Calling a remote method is simple as calling any other JavaScript function. The example above can be changed to:
```javascript
// Create the service binding
var url = "http://api.opensubtitles.org/xml-rpc";
var service = XmlRpcMessageService.bind(url);
// Call the service method as a native JS function
var result = service.LogIn("", "", "he", "OS Test User Agent");
var token = result.token;
```
This is done with the following assumptions:
* The server supports the `system.listMethods` method.  
  If this is not true, the array of method names can be given as the 2nd argument to the `bind` method.
* The response contains at most one `param` element (if not a `fault` response).
* Any fault response is handled as an `Error` and is thrown.<commit_msg>Re-arrange the readme<commit_after># XmlRpcMessageService

A service for simplifying the usage of [XML-RPC](http://xmlrpc.scripting.com/spec.html) services from JavaScript in Google Apps Script. To include this library in your project, add the following project key to your dependencies:
`<KEY>`

# Service Binding

A simple API can be achieved using service binding. In this option, a service object is created with binding to a server URL. The service object then has native JavaScript functions for each remote server method. Calling a remote method is simple as calling any other JavaScript function. The following is an example for calling the login method of [OpenSubtitles.org](http://www.opensubtitles.org) service:
```javascript
// Create the service binding
var url = "http://api.opensubtitles.org/xml-rpc";
var service = XmlRpcMessageService.bind(url);
// Call the service method as a native JS function
var result = service.LogIn("", "", "he", "OS Test User Agent");
var token = result.token;
```
This is done with the following assumptions:
* The server supports the `system.listMethods` method.  
  If this is not true, the array of method names can be given as the 2nd argument to the `bind` method.
* The response contains at most one `param` element (if not a `fault` response).
* Any fault response is handled as an `Error` and is thrown.

# Advanced Usage

A more advanced and flexible option is to do the method calls yourself. For this you can use methods to create method call XML from a simple JavaScript object, and parsing method response XML to a JavaScript object.
This service also provides a method for posting method calls to a URL and parse the response.
The example above can be written as:
```javascript
function login() {
  Logger.log("Logging in...");
  var methodCall = {
    methodName : "LogIn",
    params : [ "", "", "en", "OS Test User Agent" ]
  };
  var url = "http://api.opensubtitles.org/xml-rpc";
  var methodResponse;
  XmlRpcMessageService.execMethodCall(url, methodCall, function(mr) { methodResponse = mr; });
  var token = methodResponse.params[0].token;
  Logger.log('Logged in. Token: ' + token);
  return token;
}
```

# Limitations

* The supported data types are:
  * `string`
  * `double`
  * `int` (only in response)
  * `boolean`
  * `struct`
  * `array`
{'fraction_non_alphanumeric': 0.0971854702910753, 'fraction_numerical': 0.0009622323791195574, 'mean_word_length': 4.290076335877862, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4414898', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1123, 'n_words': 530}