Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
denysvitali committed Aug 1, 2020
1 parent 5100b2d commit 538c7a5
Show file tree
Hide file tree
Showing 8 changed files with 4,445 additions and 7 deletions.
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/fiorix/wsdl2go

go 1.14

require (
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20190107155100-1a61f4433d85
golang.org/x/text v0.3.0 // indirect
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20190107155100-1a61f4433d85 h1:3DfFuyqY+mca6oIDfim5rft3+Kl/CHLe7RdPrUMzwv0=
golang.org/x/net v0.0.0-20190107155100-1a61f4433d85/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15 changes: 11 additions & 4 deletions wsdlgo/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"go/parser"
"go/token"
"io"
"log"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -1369,8 +1368,16 @@ func (ge *goEncoder) genGoOpStruct(w io.Writer, d *wsdl.Definitions, bo *wsdl.Bi
name := goSymbol(bo.Name)
function := ge.funcs[name]

if function == nil {
function = ge.funcs[bo.Name]
}

if function == nil {
return nil
}

if function.Input == nil {
log.Printf("function input is nil! %v is %v", name, function)
//log.Printf("function input is nil! %v is %v", name, function)
} else {
message := trimns(function.Input.Message)
inputMessage := ge.messages[message]
Expand All @@ -1383,7 +1390,7 @@ func (ge *goEncoder) genGoOpStruct(w io.Writer, d *wsdl.Definitions, bo *wsdl.Bi
}

if function.Output == nil {
log.Printf("function output is nil! %v is %v", name, function)
//log.Printf("function output is nil! %v is %v", name, function)
} else {
// Output messages are always required
ge.genOpStructMessage(w, d, name, ge.messages[trimns(ge.funcs[bo.Name].Output.Message)])
Expand All @@ -1409,7 +1416,7 @@ func (ge *goEncoder) genStructFields(w io.Writer, d *wsdl.Definitions, ct *wsdl.
func (ge *goEncoder) genOpStructMessage(w io.Writer, d *wsdl.Definitions, name string, message *wsdl.Message) {
sanitizedMessageName := ge.sanitizedOperationsType(message.Name)

ge.writeComments(w, sanitizedMessageName, "Operation wrapper for "+name+".")
ge.writeComments(w, sanitizedMessageName, "Operation wrapper for "+goSymbol(name)+".")
ge.writeComments(w, sanitizedMessageName, "")
fmt.Fprintf(w, "type %s struct {\n", sanitizedMessageName)
if elName, ok := ge.needsTag[sanitizedMessageName]; ok {
Expand Down
7 changes: 4 additions & 3 deletions wsdlgo/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"testing"

"github.com/fiorix/wsdl2go/wsdl"
"github.com/stretchr/testify/assert"
)

func LoadDefinition(t *testing.T, filename string, want error) *wsdl.Definitions {
Expand Down Expand Up @@ -56,6 +57,8 @@ var EncoderCases = []struct {
{F: "localimport-url.wsdl", G: "localimport.golden", E: nil},
{F: "localimport_choice.wsdl", G: "localimport_choice.golden", E: nil},
{F: "arrayexample.wsdl", G: "arrayexample.golden", E: nil},
{F: "radioreference.wsdl", G: "radioreference.golden", E: nil},
{F: "scannerservice.wsdl", G: "scannerservice.golden", E: nil},
}

func NewTestServer(t *testing.T) *httptest.Server {
Expand Down Expand Up @@ -92,9 +95,7 @@ func TestEncoder(t *testing.T) {
t.Errorf("test %d: missing golden file %q: %v", i, tc.G, err)
}
if !bytes.Equal(have.Bytes(), want) {
err := Diff("_diff", "go", want, have.Bytes())
t.Errorf("test %d, %q != %q: %v\ngenerated:\n%s\n",
i, tc.F, tc.G, err, have.Bytes())
assert.Equal(t, string(want), string(have.Bytes()))
}
}
}
Expand Down
2,093 changes: 2,093 additions & 0 deletions wsdlgo/testdata/radioreference.golden

Large diffs are not rendered by default.

Loading

0 comments on commit 538c7a5

Please sign in to comment.