diff --git a/cli.go b/cli.go index b102169..d87e2ea 100644 --- a/cli.go +++ b/cli.go @@ -7,7 +7,7 @@ import ( "os" "runtime" - gen "github.com/cloudescape/gowsdl/generator" + gen "github.com/tgulacsi/gowsdl/generator" flags "github.com/jessevdk/go-flags" ) diff --git a/generator/gowsdl.go b/generator/gowsdl.go index ef38e8b..6e6596a 100644 --- a/generator/gowsdl.go +++ b/generator/gowsdl.go @@ -253,6 +253,7 @@ func (g *GoWsdl) genOperations() ([]byte, error) { "makePublic": makePublic, "findType": g.findType, "findSoapAction": g.findSoapAction, + "findServiceAddress": g.findServiceAddress, } data := new(bytes.Buffer) @@ -421,6 +422,17 @@ func (g *GoWsdl) findSoapAction(operation, portType string) string { return "" } +func (g *GoWsdl) findServiceAddress(name string) string { + for _, service := range g.wsdl.Service { + for _, port := range service.Ports { + if port.Name == name { + return port.SoapAddress.Location + } + } + } + return "" +} + // TODO(c4milo): Add namespace support instead of stripping it func stripns(xsdType string) string { r := strings.Split(xsdType, ":") diff --git a/generator/operations_tmpl.go b/generator/operations_tmpl.go index 1cfe2de..b42c766 100644 --- a/generator/operations_tmpl.go +++ b/generator/operations_tmpl.go @@ -8,6 +8,9 @@ var opsTmpl = ` } func New{{$portType}}(url string, tls bool) *{{$portType}} { + if url == "" { + url = {{findServiceAddress .Name | printf "%q"}} + } client := gowsdl.NewSoapClient(url, tls) return &{{$portType}}{