diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..723f762 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 5f53e11..ef57536 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,11 @@ Generates Go code from a WSDL file. +### Install + +* [Download binary release](https://github.com/hooklift/gowsdl/releases) +* Or: `go get github.com/hooklift/gowsdl/...` + ### Goals * Generate idiomatic Go code as much as possible * Support only Document/Literal wrapped services, which are [WS-I](http://ws-i.org/) compliant diff --git a/doc.go b/doc.go deleted file mode 100644 index f4b4597..0000000 --- a/doc.go +++ /dev/null @@ -1,71 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/* - -Gowsdl generates Go code from a WSDL file. - -This project is originally intended to generate Go clients for WS-* services. - -Usage: - gowsdl [OPTIONS] - -Application Options: - -v, --version - Shows gowsdl version - -p, --package=myservice - Package under which code will be generated - -o, --output=myservice.go - File where the generated code will be saved - -i, --ignore-tls - Ignores invalid TLS certificates. It is not recomended for production. - Use at your own risk. - - -Help Options: - -h, --help - Show this help message - -Features - -Supports only Document/Literal wrapped services, which are WS-I (http://ws-i.org/) compliant. - -Attempts to generate idiomatic Go code as much as possible. - -Generates Go code in parallel: types, operations and soap proxy. - -Supports WSDL 1.1, XML Schema 1.0, SOAP 1.1. - -Resolves external XML Schemas recursively, up to 5 recursions. - -Supports providing WSDL HTTP URL as well as a local WSDL file. - -Not supported - -Setting SOAP headers. - -SOAP 1.2 and HTTP port bindings. - -WS-Security. - -WS-Addressing. - -MTOM binary attachments. - -UDDI. - -TODO - -Add support for filters to allow the user to change the generated code. - -If WSDL file is local, resolve external XML schemas locally too instead of failing due to not having a URL to download them from. - -Resolve XSD element references. - -Support for generating namespaces. - -Make code generation agnostic so generating code to other programming languages is feasible through plugins. - -*/ -package main diff --git a/generator/fixtures/chromedata.wsdl b/fixtures/chromedata.wsdl similarity index 100% rename from generator/fixtures/chromedata.wsdl rename to fixtures/chromedata.wsdl diff --git a/generator/fixtures/dyndns.wsdl b/fixtures/dyndns.wsdl similarity index 100% rename from generator/fixtures/dyndns.wsdl rename to fixtures/dyndns.wsdl diff --git a/generator/fixtures/ec2.wsdl b/fixtures/ec2.wsdl similarity index 100% rename from generator/fixtures/ec2.wsdl rename to fixtures/ec2.wsdl diff --git a/generator/fixtures/ferry.wsdl b/fixtures/ferry.wsdl similarity index 100% rename from generator/fixtures/ferry.wsdl rename to fixtures/ferry.wsdl diff --git a/generator/fixtures/mnb-exchange.wsdl b/fixtures/mnb-exchange.wsdl similarity index 100% rename from generator/fixtures/mnb-exchange.wsdl rename to fixtures/mnb-exchange.wsdl diff --git a/generator/fixtures/stock.wsdl b/fixtures/stock.wsdl similarity index 100% rename from generator/fixtures/stock.wsdl rename to fixtures/stock.wsdl diff --git a/generator/fixtures/usda-awdb.wsdl b/fixtures/usda-awdb.wsdl similarity index 100% rename from generator/fixtures/usda-awdb.wsdl rename to fixtures/usda-awdb.wsdl diff --git a/generator/fixtures/vboxweb.wsdl b/fixtures/vboxweb.wsdl similarity index 100% rename from generator/fixtures/vboxweb.wsdl rename to fixtures/vboxweb.wsdl diff --git a/generator/fixtures/vim.wsdl b/fixtures/vim.wsdl similarity index 100% rename from generator/fixtures/vim.wsdl rename to fixtures/vim.wsdl diff --git a/generator/gowsdl.go b/gowsdl.go similarity index 99% rename from generator/gowsdl.go rename to gowsdl.go index f6599e8..63c14b8 100644 --- a/generator/gowsdl.go +++ b/gowsdl.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl import ( "bytes" diff --git a/generator/header_tmpl.go b/header_tmpl.go similarity index 96% rename from generator/header_tmpl.go rename to header_tmpl.go index cc0e386..caeb4db 100644 --- a/generator/header_tmpl.go +++ b/header_tmpl.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl var headerTmpl = ` package {{.}} diff --git a/main.go b/main.go deleted file mode 100644 index 71b95f6..0000000 --- a/main.go +++ /dev/null @@ -1,93 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -package main - -import ( - "bytes" - "flag" - "go/format" - "log" - "os" - "fmt" - - gen "github.com/hooklift/gowsdl/generator" -) - -const version = "v0.0.1" - -var vers = flag.Bool("v", false, "Shows gowsdl version") -var pkg = flag.String("p", "myservice", "Package under which code will be generated") -var outFile = flag.String("o", "myservice.go", "File where the generated code will be saved") - - -func init() { - log.SetFlags(0) - log.SetOutput(os.Stdout) - log.SetPrefix("🍀 ") -} - -func main() { - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "Usage: %s [options] myservice.wsdl\n", os.Args[0]) - flag.PrintDefaults() - } - - flag.Parse() - - // Show app version - if *vers { - log.Println(version) - os.Exit(0) - } - - if len(os.Args) < 2 { - flag.Usage() - os.Exit(0) - } - - wsdlPath := os.Args[len(os.Args)-1] - - if *outFile == wsdlPath { - log.Fatalln("Output file cannot be the same WSDL file") - } - - // load wsdl - gowsdl, err := gen.NewGoWsdl(wsdlPath, *pkg, false) - if err != nil { - log.Fatalln(err) - } - - // generate code - gocode, err := gowsdl.Start() - if err != nil { - log.Fatalln(err) - } - - pkg := "./" + *pkg - err = os.Mkdir(pkg, 0744) - - fd, err := os.Create(pkg + "/" + *outFile) - if err != nil { - log.Fatalln(err) - } - defer fd.Close() - - data := new(bytes.Buffer) - data.Write(gocode["header"]) - data.Write(gocode["types"]) - data.Write(gocode["operations"]) - data.Write(gocode["soap"]) - - // go fmt the generated code - source, err := format.Source(data.Bytes()) - if err != nil { - fd.Write(data.Bytes()) - log.Fatalln(err) - } - - fd.Write(source) - - log.Println("Done 💩") -} diff --git a/generator/operations_tmpl.go b/operations_tmpl.go similarity index 98% rename from generator/operations_tmpl.go rename to operations_tmpl.go index 8f01171..6145eb2 100644 --- a/generator/operations_tmpl.go +++ b/operations_tmpl.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl var opsTmpl = ` {{range .}} diff --git a/generator/soap_tmpl.go b/soap_tmpl.go similarity index 99% rename from generator/soap_tmpl.go rename to soap_tmpl.go index ebfb22f..72527fe 100644 --- a/generator/soap_tmpl.go +++ b/soap_tmpl.go @@ -1,4 +1,4 @@ -package generator +package gowsdl var soapTmpl = ` var timeout = time.Duration(30 * time.Second) diff --git a/generator/types_tmpl.go b/types_tmpl.go similarity index 99% rename from generator/types_tmpl.go rename to types_tmpl.go index ac020d4..650a659 100644 --- a/generator/types_tmpl.go +++ b/types_tmpl.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl var typesTmpl = ` {{define "SimpleType"}} diff --git a/generator/wsdl.go b/wsdl.go similarity index 99% rename from generator/wsdl.go rename to wsdl.go index 81c60ba..8358d71 100644 --- a/generator/wsdl.go +++ b/wsdl.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl type Wsdl struct { Name string `xml:"name,attr"` diff --git a/generator/wsdl_test.go b/wsdl_test.go similarity index 96% rename from generator/wsdl_test.go rename to wsdl_test.go index 7ab2a1b..e2dc4d6 100644 --- a/generator/wsdl_test.go +++ b/wsdl_test.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl import ( "encoding/xml" diff --git a/generator/xsd.go b/xsd.go similarity index 99% rename from generator/xsd.go rename to xsd.go index d577229..0964ec4 100644 --- a/generator/xsd.go +++ b/xsd.go @@ -1,7 +1,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package generator +package gowsdl import ( "encoding/xml"