• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

fixtures/H10-Mar-2020-

LICENSEH A D10-Mar-20201 KiB

README.mdH A D10-Mar-20202.9 KiB

client.goH A D10-Mar-20203.2 KiB

client_test.goH A D10-Mar-20203.9 KiB

decoder.goH A D10-Mar-20209.5 KiB

decoder_test.goH A D10-Mar-20207 KiB

encoder.goH A D10-Mar-20203.8 KiB

encoder_test.goH A D10-Mar-20203.5 KiB

is_zero.goH A D10-Mar-2020991

request.goH A D10-Mar-20201.1 KiB

response.goH A D10-Mar-2020737

response_test.goH A D10-Mar-20201.6 KiB

test_server.rbH A D10-Mar-2020340

README.md

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