wsdlparser

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-wsdl-parser

A Go library for parsing WSDL (Web Services Description Language) files. Supports WSDL 1.1 and 2.0 with SOAP 1.1/1.2 bindings.

Features

  • Automatic WSDL version detection (1.1 and 2.0)
  • SOAP 1.1 and 1.2 binding support
  • XSD schema extraction and resolution
  • Handles element-based, type-based, and composite messages
  • Generates synthetic XSD schemas for non-element message parts

Installation

go get github.com/outofcoffee/go-wsdl-parser

Usage

import "github.com/outofcoffee/go-wsdl-parser"

parser, err := wsdlparser.NewWSDLParser("path/to/service.wsdl")
if err != nil {
    log.Fatal(err)
}

// List all operations
for name, op := range parser.GetOperations() {
    fmt.Printf("Operation: %s (SOAPAction: %s)\n", name, op.SOAPAction)
}

// Get a specific operation
op := parser.GetOperation("GetWeather")

// Access the schema system for XSD resolution
schemas := parser.GetSchemaSystem()

The parser returns Operation structs containing input, output, and fault messages. Each message references an XSD element that can be resolved through the schema system.

Packages

Package Description
wsdlparser Main parser interface and WSDL 1.1/2.0 implementations
wsdlmsg Message types and synthetic schema generation
xsd XSD schema processing, imports, and resolution

Contributing

# Run tests
go test -v ./...

# Run tests with race detection
go test -race ./...

Requires Go 1.23+.

Licence

Apache 2.0 - see LICENSE.

Documentation

Index

Constants

View Source
const (
	WSDL1Namespace = "http://schemas.xmlsoap.org/wsdl/"
	WSDL2Namespace = "http://www.w3.org/ns/wsdl"
)
View Source
const (
	StyleDocument = "document"
	StyleRPC      = "rpc"
)

Operation style constants. Mirrors the WSDL 1.1 soap:binding / soap:operation style attribute values.

Variables

This section is empty.

Functions

func GetLocalPart

func GetLocalPart(qname string) string

GetLocalPart extracts the local part from a QName

func GetPrefix

func GetPrefix(qname string) string

GetPrefix extracts the prefix from a QName

Types

type BaseWSDLParser

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

BaseWSDLParser provides common functionality for WSDL parsers

func (*BaseWSDLParser) GetBindingName

func (p *BaseWSDLParser) GetBindingName(op *Operation) string

GetBindingName returns the binding name for the given operation

func (*BaseWSDLParser) GetNamespaceByPrefix

func (p *BaseWSDLParser) GetNamespaceByPrefix(prefix string) string

GetNamespaceByPrefix returns the namespace URI for a given prefix

func (*BaseWSDLParser) GetOperation

func (p *BaseWSDLParser) GetOperation(name string) *Operation

GetOperation returns the operation by name

func (*BaseWSDLParser) GetOperations

func (p *BaseWSDLParser) GetOperations() map[string]*Operation

GetOperations returns all operations

func (*BaseWSDLParser) GetSchemaSystem

func (p *BaseWSDLParser) GetSchemaSystem() *xsd.SchemaSystem

GetSchemaSystem returns the schema system

func (*BaseWSDLParser) GetTargetNamespace

func (p *BaseWSDLParser) GetTargetNamespace() string

GetTargetNamespace returns the target namespace of the WSDL document

func (*BaseWSDLParser) GetWSDLDoc

func (p *BaseWSDLParser) GetWSDLDoc() *xmlquery.Node

GetWSDLDoc returns the WSDL document

func (*BaseWSDLParser) GetWSDLPath

func (p *BaseWSDLParser) GetWSDLPath() string

type Operation

type Operation struct {
	Name       string
	SOAPAction string
	Input      *wsdlmsg.Message
	Output     *wsdlmsg.Message
	Fault      *wsdlmsg.Message
	Binding    string
	// Style is the SOAP binding style for this operation, either
	// "document" (default) or "rpc". Resolved from the soap:operation
	// element's style attribute, falling back to the enclosing
	// soap:binding element.
	Style string
}

Operation represents a WSDL operation

type WSDLDocProvider

type WSDLDocProvider interface {
	GetWSDLDoc() *xmlquery.Node
	GetWSDLPath() string
	GetSchemaSystem() *xsd.SchemaSystem
}

WSDLDocProvider is the interface that provides the WSDL document

type WSDLParser

type WSDLParser interface {
	WSDLDocProvider
	GetVersion() WSDLVersion
	GetOperations() map[string]*Operation
	GetOperation(name string) *Operation
	ValidateRequest(operation string, body []byte) error
	GetBindingName(op *Operation) string
	GetTargetNamespace() string
}

WSDLParser is the interface that all WSDL parsers must implement

func NewWSDLParser

func NewWSDLParser(wsdlPath string) (WSDLParser, error)

NewWSDLParser creates a new version-aware WSDL parser instance

type WSDLVersion

type WSDLVersion int

WSDLVersion represents the version of WSDL being used

const (
	WSDL1 WSDLVersion = iota + 1
	WSDL2
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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