Skip to content

Commit 71a357c

Browse files
author
Tamás Gulácsi
committed
generator: add findServiceAddress and use it to find the default wsdl port address in New{{$portType}}
1 parent a731c50 commit 71a357c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
"runtime"
99

10-
gen "github.com/cloudescape/gowsdl/generator"
10+
gen "github.com/tgulacsi/gowsdl/generator"
1111
flags "github.com/jessevdk/go-flags"
1212
)
1313

generator/gowsdl.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ func (g *GoWsdl) genOperations() ([]byte, error) {
253253
"makePublic": makePublic,
254254
"findType": g.findType,
255255
"findSoapAction": g.findSoapAction,
256+
"findServiceAddress": g.findServiceAddress,
256257
}
257258

258259
data := new(bytes.Buffer)
@@ -421,6 +422,17 @@ func (g *GoWsdl) findSoapAction(operation, portType string) string {
421422
return ""
422423
}
423424

425+
func (g *GoWsdl) findServiceAddress(name string) string {
426+
for _, service := range g.wsdl.Service {
427+
for _, port := range service.Ports {
428+
if port.Name == name {
429+
return port.SoapAddress.Location
430+
}
431+
}
432+
}
433+
return ""
434+
}
435+
424436
// TODO(c4milo): Add namespace support instead of stripping it
425437
func stripns(xsdType string) string {
426438
r := strings.Split(xsdType, ":")

generator/operations_tmpl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var opsTmpl = `
88
}
99
1010
func New{{$portType}}(url string, tls bool) *{{$portType}} {
11+
if url == "" {
12+
url = {{findServiceAddress .Name | printf "%q"}}
13+
}
1114
client := gowsdl.NewSoapClient(url, tls)
1215
1316
return &{{$portType}}{

0 commit comments

Comments
 (0)