Skip to content
An XML-RPC Client for Go
Go Shell Makefile Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dependabot
.github/workflows Adding codecov support Jan 10, 2020
hack
testdata
.editorconfig
.gitignore
CHANGELOG.md
Dockerfile Adding codecov support Jan 10, 2020
LICENSE Initial commit Jan 2, 2020
Makefile
README.md
client.go
client_test.go
codec.go Close HTTP Client connections on Codec closure. Jan 10, 2020
codecov.yaml
decode.go Supporting pointers when decoding responses. Jan 9, 2020
decode_response.go A bit of refactoring and more documentation Jan 8, 2020
decode_test.go Supporting pointers when decoding responses. Jan 9, 2020
doc.go
encode.go
encode_test.go A bit of refactoring and more documentation Jan 8, 2020
fault.go
go.mod Basic encoding implementation added Jan 5, 2020
go.sum Basic encoding implementation added Jan 5, 2020

README.md

XML-RPC Client for Go

This is an implementation of client-side part of XML-RPC protocol in Go.

GitHub Workflow Status codecov Go Report Card

GoDoc GitHub GitHub release (latest SemVer)

Usage

Add dependency to your project:

go get -u alexejk.io/go-xmlrpc

Use it by creating an *xmlrpc.Client and firing RPC method calls with Call().

package main

import(
    "fmt"

    "alexejk.io/go-xmlrpc"
)

func main() {
    client, _ := xmlrpc.NewClient("https://bugzilla.mozilla.org/xmlrpc.cgi")

    result := &struct {
        BugzillaVersion struct {
            Version string
        }
    }{}

    _ = client.Call("Bugzilla.version", nil, result)
    fmt.Printf("Version: %s\n", result.BugzillaVersion.Version)
}

If you want to customize any aspect of http.Client used to perform requests, use NewClientWithHttpClient instead. By default http.DefaultClient will be used.

Argument encoding

Arguments to the remote RPC method are passed on as a *struct. This struct is encoded into XML-RPC types based on following rules:

  • Order of fields in struct type matters - fields are taken in the order they are defined on the type.
  • Numbers are to be specified as int (encoded as <int>) or float64 (encoded as <double>)
  • Both pointer and value references are accepted (pointers are followed to actual values)

Response decoding

Response is decoded following similar rules to argument encoding.

  • Order of fields is important.
  • Outer struct should contain exported field for each response parameter.
  • Structs may contain pointers - they will be initialized if required.

Building

To build this project, simply run make all. If you prefer building in Docker instead - make build-in-docker is your friend.

You can’t perform that action at this time.