Skip to content

Commit

Permalink
generator: add findServiceAddress and use it to find the default wsdl…
Browse files Browse the repository at this point in the history
… port address in New{{$portType}}
  • Loading branch information
Tamás Gulácsi committed Sep 2, 2014
1 parent a731c50 commit 71a357c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
12 changes: 12 additions & 0 deletions generator/gowsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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, ":")
Expand Down
3 changes: 3 additions & 0 deletions generator/operations_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}{
Expand Down

0 comments on commit 71a357c

Please sign in to comment.