From f28426846fffd2938506af12d17908d10479e9b6 Mon Sep 17 00:00:00 2001 From: "Babani, Denis" Date: Thu, 20 Oct 2016 13:02:00 -0400 Subject: [PATCH 1/2] adding support for xsd:import --- gowsdl.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/gowsdl.go b/gowsdl.go index c042107..083db84 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -185,23 +185,22 @@ func (g *GoWSDL) unmarshal() error { } func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, url *url.URL) error { - for _, incl := range schema.Includes { - location, err := url.Parse(incl.SchemaLocation) + 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) @@ -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) @@ -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 From 99e3a00a04447bc367f73c2ef144685baa537ade Mon Sep 17 00:00:00 2001 From: "Babani, Denis" Date: Thu, 20 Oct 2016 13:54:25 -0400 Subject: [PATCH 2/2] adding support for xsd:import --- gowsdl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gowsdl.go b/gowsdl.go index 083db84..e136e27 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -184,7 +184,7 @@ func (g *GoWSDL) unmarshal() error { return nil } -func (g *GoWSDL) resolveXSDExternals(schema *XSDSchema, url *url.URL) error { +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 {