Command line tool to generate Go code from WSDL
Go Shell
Latest commit 4ad5742 Jan 20, 2017 @fiorix Add support for new types, and bug fixes
This commit adds support for token, anyURI, QName and unions as
described in the README.

The token and anyURI types are implemented as strings. The QName is
currently implemented as a string too but we might have to change it
whenever it causes trouble.

The union type is currently implemented as an empty interface with a
comment about the types accepted in the union. Later on we could have a
validator for that.

The "any" element of sequences in complex types is also supported now,
as a slice of empty interfaces, and the nonNegativeInteger type is
implemented as uint.

Restricted elements of complex types are still not implemented, the
likes of pattern matching (in a validation function) are lacking.

Functions in interfaces and methods in structs are now sorted by name.
This required a change in the memcache.golden file of unit tests.

One more important thing is that elements without a type are
automatically set to the string type. I dont know if this is right but
it works for now. yolo

Closes #20


wsdl2go is a command line tool to generate Go code from WSDL.


go get


Make sure you have gofmt under $GOROOT/bin (otherwise it will look for gofmt in your $PATH if $GOROOT is not defined), otherwise it'll fail.

wsdl2go < file.wsdl > hello.go

Use -i for files or URLs, and -o to specify an output file. WSDL files that contain import tags are only processed after these resources are downloaded. It tries automatically but might fail due to authentication or bad SSL certificates. You can force it anyway. YOLO.

Here's how to use the generated code: Let's say you generate the Go code for the hello service, which provides an Echo method that takes an EchoRequest and returns an EchoReply. To use it, you have to create a SOAP client, then call the generated function Echo.


import (


func main() {
    cli := soap.Client{
        URL: "http://server",
        Namespace: hello.Namespace,
    conn := hello.NewService(&cli)
    reply, err := conn.Echo(cli, &hello.EchoRequest{Data: "echo"})

Only the Document style of SOAP is supported. If you're looking for the RPC one, take another bite of your taco and move on. Soz.


Works for my needs, been tested with a few SOAP enterprise systems. Not fully compliant to WSDL or SOAP specs.

Because of some limitations of XML namespaces in Go, there's only so much one can do to make things like SOAP work properly. Although, the code generated by wsdl2go might be sufficient for most systems.

Types supported:

  • int
  • long (int64)
  • float (float64)
  • double (float64)
  • boolean (bool)
  • string
  • hexBinary ([]byte)
  • base64Binary ([]byte)
  • date
  • time
  • dateTime
  • simpleType (w/ enum and validation)
  • complexType (struct)
  • complexContent (slices, embedded structs)
  • token (as string)
  • any (slice of empty interfaces)
  • anyURI (string)
  • QName (string)
  • union (empty interface w/ comments)
  • nonNegativeInteger (uint)
  • faults
  • decimal
  • g{Day,Month,Year}...

Date types are currently defined as strings, need to implement XML Marshaler and Unmarshaler interfaces. The binary ones (hex and base64) are also lacking marshal/unmarshal.

For simple types that have restrictions defined, such as an enumerated list of possible values, we generate the validation function using reflect to compare values. This and the entire API might change anytime, be warned.