gowsdl

package module
Version: v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2021 License: MPL-2.0 Imports: 18 Imported by: 26

README

WSDL to Go

Gitter GoDoc Build Status

Generates Go code from a WSDL file.

Install
  • Download binary release
  • Download and build locally: go get github.com/hooklift/gowsdl/...
  • Install from Homebrew: brew install gowsdl
Goals
  • Generate idiomatic Go code as much as possible
  • Support only Document/Literal wrapped services, which are WS-I compliant
  • Support:
    • WSDL 1.1
    • XML Schema 1.0
    • SOAP 1.1
  • Resolve external XML Schemas
  • Support external and local WSDL
Caveats
  • Please keep in mind that the generated code is just a reflection of what the WSDL is like. If your WSDL has duplicated type definitions, your Go code is going to have the same and may not compile.
Usage
Usage: gowsdl [options] myservice.wsdl
  -o string
        File where the generated code will be saved (default "myservice.go")
  -p string
        Package under which code will be generated (default "myservice")
  -i    Skips TLS Verification
  -v    Shows gowsdl version

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoWSDL

type GoWSDL struct {
	// contains filtered or unexported fields
}

GoWSDL defines the struct for WSDL generator.

func NewGoWSDL

func NewGoWSDL(file, pkg string, ignoreTLS bool, exportAllTypes bool) (*GoWSDL, error)

NewGoWSDL initializes WSDL generator.

func (*GoWSDL) Start

func (g *GoWSDL) Start() (map[string][]byte, error)

Start initiaties the code generation process by starting two goroutines: one to generate types and another one to generate operations.

type Location added in v0.3.0

type Location struct {
	// contains filtered or unexported fields
}

A Location encapsulate information about the loc of WSDL/XSD.

It could be either URL or an absolute file path.

func ParseLocation added in v0.3.0

func ParseLocation(rawloc string) (*Location, error)

ParseLocation parses a rawloc into a Location structure.

If rawloc is URL then it should be absolute. Relative file path will be converted into absolute path.

func (*Location) Parse added in v0.3.0

func (r *Location) Parse(ref string) (*Location, error)

Parse parses path in the context of the receiver. The provided path may be relative or absolute. Parse returns nil, err on parse failure.

func (*Location) String added in v0.3.0

func (r *Location) String() string

String reassembles the Location either into a valid URL string or a file path.

type WSDL

type WSDL struct {
	Xmlns           map[string]string `xml:"-"`
	Name            string            `xml:"name,attr"`
	TargetNamespace string            `xml:"targetNamespace,attr"`
	Imports         []*WSDLImport     `xml:"import"`
	Doc             string            `xml:"documentation"`
	Types           WSDLType          `xml:"http://schemas.xmlsoap.org/wsdl/ types"`
	Messages        []*WSDLMessage    `xml:"http://schemas.xmlsoap.org/wsdl/ message"`
	PortTypes       []*WSDLPortType   `xml:"http://schemas.xmlsoap.org/wsdl/ portType"`
	Binding         []*WSDLBinding    `xml:"http://schemas.xmlsoap.org/wsdl/ binding"`
	Service         []*WSDLService    `xml:"http://schemas.xmlsoap.org/wsdl/ service"`
}

WSDL represents the global structure of a WSDL file.

func (*WSDL) UnmarshalXML added in v0.3.0

func (w *WSDL) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements interface xml.Unmarshaler for XSDSchema.

type WSDLBinding

type WSDLBinding struct {
	Name        string           `xml:"name,attr"`
	Type        string           `xml:"type,attr"`
	Doc         string           `xml:"documentation"`
	SOAPBinding WSDLSOAPBinding  `xml:"http://schemas.xmlsoap.org/wsdl/soap/ binding"`
	Operations  []*WSDLOperation `xml:"http://schemas.xmlsoap.org/wsdl/ operation"`
}

WSDLBinding defines only a SOAP binding and its operations

type WSDLFault

type WSDLFault struct {
	Name      string        `xml:"name,attr"`
	Message   string        `xml:"message,attr"`
	Doc       string        `xml:"documentation"`
	SOAPFault WSDLSOAPFault `xml:"http://schemas.xmlsoap.org/wsdl/soap/ fault"`
}

WSDLFault represents a WSDL fault message.

type WSDLImport

type WSDLImport struct {
	Namespace string `xml:"namespace,attr"`
	Location  string `xml:"location,attr"`
}

WSDLImport is the struct used for deserializing WSDL imports.

type WSDLInput

type WSDLInput struct {
	Name       string            `xml:"name,attr"`
	Message    string            `xml:"message,attr"`
	Doc        string            `xml:"documentation"`
	SOAPBody   WSDLSOAPBody      `xml:"http://schemas.xmlsoap.org/wsdl/soap/ body"`
	SOAPHeader []*WSDLSOAPHeader `xml:"http://schemas.xmlsoap.org/wsdl/soap/ header"`
}

WSDLInput represents a WSDL input message.

type WSDLMessage

type WSDLMessage struct {
	Name  string      `xml:"name,attr"`
	Doc   string      `xml:"documentation"`
	Parts []*WSDLPart `xml:"http://schemas.xmlsoap.org/wsdl/ part"`
}

WSDLMessage represents a function, which in turn has one or more parameters.

type WSDLOperation

type WSDLOperation struct {
	Name          string            `xml:"name,attr"`
	Doc           string            `xml:"documentation"`
	Input         WSDLInput         `xml:"input"`
	Output        WSDLOutput        `xml:"output"`
	Faults        []*WSDLFault      `xml:"fault"`
	SOAPOperation WSDLSOAPOperation `xml:"http://schemas.xmlsoap.org/wsdl/soap/ operation"`
}

WSDLOperation represents the contract of an entire operation or function.

type WSDLOutput

type WSDLOutput struct {
	Name       string            `xml:"name,attr"`
	Message    string            `xml:"message,attr"`
	Doc        string            `xml:"documentation"`
	SOAPBody   WSDLSOAPBody      `xml:"http://schemas.xmlsoap.org/wsdl/soap/ body"`
	SOAPHeader []*WSDLSOAPHeader `xml:"http://schemas.xmlsoap.org/wsdl/soap/ header"`
}

WSDLOutput represents a WSDL output message.

type WSDLPart

type WSDLPart struct {
	Name    string `xml:"name,attr"`
	Element string `xml:"element,attr"`
	Type    string `xml:"type,attr"`
}

WSDLPart defines the struct for a function parameter within a WSDL.

type WSDLPort

type WSDLPort struct {
	Name        string          `xml:"name,attr"`
	Binding     string          `xml:"binding,attr"`
	Doc         string          `xml:"documentation"`
	SOAPAddress WSDLSOAPAddress `xml:"http://schemas.xmlsoap.org/wsdl/soap/ address"`
}

WSDLPort defines the properties for a SOAP port only.

type WSDLPortType

type WSDLPortType struct {
	Name       string           `xml:"name,attr"`
	Doc        string           `xml:"documentation"`
	Operations []*WSDLOperation `xml:"http://schemas.xmlsoap.org/wsdl/ operation"`
}

WSDLPortType defines the service, operations that can be performed and the messages involved. A port type can be compared to a function library, module or class.

type WSDLSOAPAddress

type WSDLSOAPAddress struct {
	Location string `xml:"location,attr"`
}

WSDLSOAPAddress defines the location for the SOAP service.

type WSDLSOAPBinding

type WSDLSOAPBinding struct {
	Style     string `xml:"style,attr"`
	Transport string `xml:"transport,attr"`
}

WSDLSOAPBinding represents a SOAP binding to the web service.

type WSDLSOAPBody

type WSDLSOAPBody struct {
	Parts         string `xml:"parts,attr"`
	Use           string `xml:"use,attr"`
	EncodingStyle string `xml:"encodingStyle,attr"`
	Namespace     string `xml:"namespace,attr"`
}

WSDLSOAPBody defines SOAP body characteristics.

type WSDLSOAPFault

type WSDLSOAPFault struct {
	Parts         string `xml:"parts,attr"`
	Use           string `xml:"use,attr"`
	EncodingStyle string `xml:"encodingStyle,attr"`
	Namespace     string `xml:"namespace,attr"`
}

WSDLSOAPFault defines a SOAP fault message characteristics.

type WSDLSOAPHeader

type WSDLSOAPHeader struct {
	Message       string                 `xml:"message,attr"`
	Part          string                 `xml:"part,attr"`
	Use           string                 `xml:"use,attr"`
	EncodingStyle string                 `xml:"encodingStyle,attr"`
	Namespace     string                 `xml:"namespace,attr"`
	HeadersFault  []*WSDLSOAPHeaderFault `xml:"headerfault"`
}

WSDLSOAPHeader defines the header for a SOAP service.

type WSDLSOAPHeaderFault

type WSDLSOAPHeaderFault struct {
	Message       string `xml:"message,attr"`
	Part          string `xml:"part,attr"`
	Use           string `xml:"use,attr"`
	EncodingStyle string `xml:"encodingStyle,attr"`
	Namespace     string `xml:"namespace,attr"`
}

WSDLSOAPHeaderFault defines a SOAP fault header.

type WSDLSOAPOperation

type WSDLSOAPOperation struct {
	SOAPAction string `xml:"soapAction,attr"`
	Style      string `xml:"style,attr"`
}

WSDLSOAPOperation represents a service operation in SOAP terms.

type WSDLService

type WSDLService struct {
	Name  string      `xml:"name,attr"`
	Doc   string      `xml:"documentation"`
	Ports []*WSDLPort `xml:"http://schemas.xmlsoap.org/wsdl/ port"`
}

WSDLService defines the list of SOAP services associated with the WSDL.

type WSDLType

type WSDLType struct {
	Doc     string       `xml:"documentation"`
	Schemas []*XSDSchema `xml:"schema"`
}

WSDLType represents the entry point for deserializing XSD schemas used by the WSDL file.

type XSDAny added in v0.4.0

type XSDAny struct {
	XMLName         xml.Name `xml:"any"`
	Doc             string   `xml:"annotation>documentation"`
	MinOccurs       string   `xml:"minOccurs,attr"`
	MaxOccurs       string   `xml:"maxOccurs,attr"`
	Namespace       string   `xml:"namespace,attr"`
	ProcessContents string   `xml:"processContents,attr"`
}

XSDAny represents a Schema element.

type XSDAttribute

type XSDAttribute struct {
	Doc        string         `xml:"annotation>documentation"`
	Name       string         `xml:"name,attr"`
	Ref        string         `xml:"ref,attr"`
	Type       string         `xml:"type,attr"`
	Use        string         `xml:"use,attr"`
	Fixed      string         `xml:"fixed,attr"`
	SimpleType *XSDSimpleType `xml:"simpleType"`
}

XSDAttribute represent an element attribute. Simple elements cannot have attributes. If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type.

type XSDComplexContent

type XSDComplexContent struct {
	XMLName   xml.Name     `xml:"complexContent"`
	Extension XSDExtension `xml:"extension"`
}

XSDComplexContent element defines extensions or restrictions on a complex type that contains mixed content or elements only.

type XSDComplexType

type XSDComplexType struct {
	XMLName        xml.Name          `xml:"complexType"`
	Abstract       bool              `xml:"abstract,attr"`
	Name           string            `xml:"name,attr"`
	Mixed          bool              `xml:"mixed,attr"`
	Sequence       []*XSDElement     `xml:"sequence>element"`
	Choice         []*XSDElement     `xml:"choice>element"`
	SequenceChoice []*XSDElement     `xml:"sequence>choice>element"`
	All            []*XSDElement     `xml:"all>element"`
	ComplexContent XSDComplexContent `xml:"complexContent"`
	SimpleContent  XSDSimpleContent  `xml:"simpleContent"`
	Attributes     []*XSDAttribute   `xml:"attribute"`
	Any            []*XSDAny         `xml:"sequence>any"`
}

XSDComplexType represents a Schema complex type.

type XSDElement

type XSDElement struct {
	XMLName     xml.Name        `xml:"element"`
	Name        string          `xml:"name,attr"`
	Doc         string          `xml:"annotation>documentation"`
	Nillable    bool            `xml:"nillable,attr"`
	Type        string          `xml:"type,attr"`
	Ref         string          `xml:"ref,attr"`
	MinOccurs   string          `xml:"minOccurs,attr"`
	MaxOccurs   string          `xml:"maxOccurs,attr"`
	ComplexType *XSDComplexType `xml:"complexType"` // local
	SimpleType  *XSDSimpleType  `xml:"simpleType"`
	Groups      []*XSDGroup     `xml:"group"`
}

XSDElement represents a Schema element.

type XSDExtension

type XSDExtension struct {
	XMLName    xml.Name        `xml:"extension"`
	Base       string          `xml:"base,attr"`
	Attributes []*XSDAttribute `xml:"attribute"`
	Sequence   []XSDElement    `xml:"sequence>element"`
	Choice     []*XSDElement   `xml:"choice>element"`
}

XSDExtension element extends an existing simpleType or complexType element.

type XSDGroup

type XSDGroup struct {
	Name     string       `xml:"name,attr"`
	Ref      string       `xml:"ref,attr"`
	Sequence []XSDElement `xml:"sequence>element"`
	Choice   []XSDElement `xml:"choice>element"`
	All      []XSDElement `xml:"all>element"`
}

XSDGroup element is used to define a group of elements to be used in complex type definitions.

type XSDImport

type XSDImport struct {
	XMLName        xml.Name `xml:"import"`
	SchemaLocation string   `xml:"schemaLocation,attr"`
	Namespace      string   `xml:"namespace,attr"`
}

XSDImport represents XSD imports within the main schema.

type XSDInclude

type XSDInclude struct {
	SchemaLocation string `xml:"schemaLocation,attr"`
}

XSDInclude represents schema includes.

type XSDList added in v0.3.0

type XSDList struct {
	Doc        string         `xml:"annotation>documentation"`
	ItemType   string         `xml:"itemType,attr"`
	SimpleType *XSDSimpleType `xml:"simpleType"`
}

XSDList represents a element list

type XSDRestriction

type XSDRestriction struct {
	Base         string                `xml:"base,attr"`
	Enumeration  []XSDRestrictionValue `xml:"enumeration"`
	Pattern      XSDRestrictionValue   `xml:"pattern"`
	MinInclusive XSDRestrictionValue   `xml:"minInclusive"`
	MaxInclusive XSDRestrictionValue   `xml:"maxInclusive"`
	WhiteSpace   XSDRestrictionValue   `xml:"whitespace"`
	Length       XSDRestrictionValue   `xml:"length"`
	MinLength    XSDRestrictionValue   `xml:"minLength"`
	MaxLength    XSDRestrictionValue   `xml:"maxLength"`
}

XSDRestriction defines restrictions on a simpleType, simpleContent, or complexContent definition.

type XSDRestrictionValue

type XSDRestrictionValue struct {
	Doc   string `xml:"annotation>documentation"`
	Value string `xml:"value,attr"`
}

XSDRestrictionValue represents a restriction value.

type XSDSchema

type XSDSchema struct {
	XMLName            xml.Name          `xml:"schema"`
	Xmlns              map[string]string `xml:"-"`
	Tns                string            `xml:"xmlns tns,attr"`
	Xs                 string            `xml:"xmlns xs,attr"`
	Version            string            `xml:"version,attr"`
	TargetNamespace    string            `xml:"targetNamespace,attr"`
	ElementFormDefault string            `xml:"elementFormDefault,attr"`
	Includes           []*XSDInclude     `xml:"include"`
	Imports            []*XSDImport      `xml:"import"`
	Elements           []*XSDElement     `xml:"element"`
	Attributes         []*XSDAttribute   `xml:"attribute"`
	ComplexTypes       []*XSDComplexType `xml:"complexType"` // global
	SimpleType         []*XSDSimpleType  `xml:"simpleType"`
}

XSDSchema represents an entire Schema structure.

func (*XSDSchema) UnmarshalXML added in v0.3.0

func (s *XSDSchema) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements interface xml.Unmarshaler for XSDSchema.

type XSDSimpleContent

type XSDSimpleContent struct {
	XMLName   xml.Name     `xml:"simpleContent"`
	Extension XSDExtension `xml:"extension"`
}

XSDSimpleContent element contains extensions or restrictions on a text-only complex type or on a simple type as content and contains no elements.

type XSDSimpleType

type XSDSimpleType struct {
	Name        string         `xml:"name,attr"`
	Doc         string         `xml:"annotation>documentation"`
	Restriction XSDRestriction `xml:"restriction"`
	List        XSDList        `xml:"list"`
	Union       XSDUnion       `xml:"union"`
	Final       string         `xml:"final"`
}

XSDSimpleType element defines a simple type and specifies the constraints and information about the values of attributes or text-only elements.

type XSDUnion added in v0.3.0

type XSDUnion struct {
	SimpleType  []*XSDSimpleType `xml:"simpleType,omitempty"`
	MemberTypes string           `xml:"memberTypes,attr"`
}

XSDUnion represents a union element

Directories

Path Synopsis
cmd
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL