Skip to content

Commit

Permalink
Merge pull request hooklift#63 from dnsserver/master
Browse files Browse the repository at this point in the history
adding support for xsd:import
  • Loading branch information
c4milo authored Nov 22, 2016
2 parents 3abbbe4 + 99e3a00 commit 62a6e2f
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions gowsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,23 @@ func (g *GoWSDL) unmarshal() error {
return nil
}

func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, url *url.URL) error {
for _, incl := range schema.Includes {
location, err := url.Parse(incl.SchemaLocation)
func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, u *url.URL) error {
download := func(u1 *url.URL, loc string) error{
location, err := u1.Parse(loc)
if err != nil {
return err
}

_, schemaName := filepath.Split(location.Path)
if g.resolvedXSDExternals[schemaName] {
continue
return nil
}

schemaLocation := location.String()
if !location.IsAbs() {
if !url.IsAbs() {
return fmt.Errorf("Unable to resolve external schema %s through WSDL URL %s", schemaLocation, url)
if !u1.IsAbs() {
return fmt.Errorf("Unable to resolve external schema %s through WSDL URL %s", schemaLocation, u1)
}
schemaLocation = url.Scheme + "://" + url.Host + schemaLocation
schemaLocation = u1.Scheme + "://" + u1.Host + schemaLocation
}

log.Println("Downloading external schema", "location", schemaLocation)
Expand All @@ -220,7 +219,7 @@ func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, url *url.URL) error {
g.currentRecursionLevel++

//log.Printf("Entering recursion %d\n", g.currentRecursionLevel)
g.resolveXSDExternals(newschema, url)
g.resolveXSDExternals(newschema, u1)
}

g.wsdl.Types.Schemas = append(g.wsdl.Types.Schemas, newschema)
Expand All @@ -229,6 +228,21 @@ func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, url *url.URL) error {
g.resolvedXSDExternals = make(map[string]bool, maxRecursion)
}
g.resolvedXSDExternals[schemaName] = true

return nil
}


for _, impts := range schema.Imports {
if e := download(u, impts.SchemaLocation); e!= nil {
return e
}
}

for _, incl := range schema.Includes {
if e := download(u, incl.SchemaLocation); e!= nil {
return e
}
}

return nil
Expand Down

0 comments on commit 62a6e2f

Please sign in to comment.