README.md
1[![GoDoc](https://godoc.org/github.com/kolo/xmlrpc?status.svg)](https://godoc.org/github.com/kolo/xmlrpc)
2
3## Overview
4
5[![Coverage Status](https://coveralls.io/repos/github/softlayer/xmlrpc/badge.svg)](https://coveralls.io/github/softlayer/xmlrpc)
6![Build](https://github.com/softlayer/xmlrpc/workflows/Go/badge.svg)
7
8
9xmlrpc is an implementation of client side part of XMLRPC protocol in Go language. This project was forked from https://github.com/kolo/xmlrpc and contains a few minor changes to help interact with the [SoftLayer API](https://sldn.softlayer.com)
10
11## Status
12
13This project is in minimal maintenance mode with no further development. Bug fixes are accepted, but it might take some time until they will be merged.
14
15## Installation
16
17To install xmlrpc package run `go get github.com/kolo/xmlrpc`. To use
18it in application add `"github.com/kolo/xmlrpc"` string to `import`
19statement.
20
21## Usage
22
23 client, _ := xmlrpc.NewClient("https://bugzilla.mozilla.org/xmlrpc.cgi", nil)
24 result := struct{
25 Version string `xmlrpc:"version"`
26 }{}
27 client.Call("Bugzilla.version", nil, &result)
28 fmt.Printf("Version: %s\n", result.Version) // Version: 4.2.7+
29
30Second argument of NewClient function is an object that implements
31[http.RoundTripper](http://golang.org/pkg/net/http/#RoundTripper)
32interface, it can be used to get more control over connection options.
33By default it initialized by http.DefaultTransport object.
34
35### Arguments encoding
36
37xmlrpc package supports encoding of native Go data types to method
38arguments.
39
40Data types encoding rules:
41
42* int, int8, int16, int32, int64 encoded to int;
43* float32, float64 encoded to double;
44* bool encoded to boolean;
45* string encoded to string;
46* time.Time encoded to datetime.iso8601;
47* xmlrpc.Base64 encoded to base64;
48* slice encoded to array;
49
50Structs decoded to struct by following rules:
51
52* all public field become struct members;
53* field name become member name;
54* if field has xmlrpc tag, its value become member name.
55
56Server method can accept few arguments, to handle this case there is
57special approach to handle slice of empty interfaces (`[]interface{}`).
58Each value of such slice encoded as separate argument.
59
60### Result decoding
61
62Result of remote function is decoded to native Go data type.
63
64Data types decoding rules:
65
66* int, i4 decoded to int, int8, int16, int32, int64;
67* double decoded to float32, float64;
68* boolean decoded to bool;
69* string decoded to string;
70* array decoded to slice;
71* structs decoded following the rules described in previous section;
72* datetime.iso8601 decoded as time.Time data type;
73* base64 decoded to string.
74
75## Implementation details
76
77xmlrpc package contains clientCodec type, that implements [rpc.ClientCodec](http://golang.org/pkg/net/rpc/#ClientCodec)
78interface of [net/rpc](http://golang.org/pkg/net/rpc) package.
79
80xmlrpc package works over HTTP protocol, but some internal functions
81and data type were made public to make it easier to create another
82implementation of xmlrpc that works over another protocol. To encode
83request body there is EncodeMethodCall function. To decode server
84response Response data type can be used.
85
86
87## Testing
88
89For a full test suite, you need to spin up the testing webserver
90`~go/src/github.com/softlayer/xmlrpc $ ruby test_server.rb`
91
92Then run the tests
93`go test -v`
94
95## Contribution
96
97See [project status](#status).
98
99## Authors
100
101Dmitry Maksimov (dmtmax@gmail.com)
102