envelope

package
v0.0.0-...-5a65ac4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package envelope is responsible for encoding and decoding SOAP envelopes.

Index

Constants

This section is empty.

Variables

View Source
var ErrFault error = errors.New("xml fault")

ErrFault can be used as a target with errors.Is.

Functions

func Read

func Read(r io.Reader, action *Action) error

Read unmarshals a SOAP envelope from the reader. Errors can either be from the reader, XML decoding, or a *Fault.

func Write

func Write(w io.Writer, action *Action) error

Write marshals a SOAP envelope to the writer. Errors can be from the writer or XML encoding.

Types

type Action

type Action struct {
	// XMLName specifies the XML element namespace (URI) and name. Together
	// these identify the SOAP action.
	XMLName xml.Name
	// Args is an arbitrary struct containing fields for encoding or decoding
	// arguments. See https://pkg.go.dev/encoding/xml@go1.17.1#Marshal and
	// https://pkg.go.dev/encoding/xml@go1.17.1#Unmarshal for details on
	// annotating fields in the structure.
	Args any
}

Action wraps a SOAP action to be read or written as part of a SOAP envelope.

func NewRecvAction

func NewRecvAction(args any) *Action

NewSendAction creates a SOAP action for receiving arguments.

func NewSendAction

func NewSendAction(serviceType, actionName string, args any) *Action

NewSendAction creates a SOAP action for sending with the given namespace URL, action name, and arguments.

func (*Action) MarshalXML

func (a *Action) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements `xml.Marshaller`.

This is an implementation detail that allows packing elements inside the action element from the struct in `a.Args`.

func (*Action) UnmarshalXML

func (a *Action) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements `xml.Unmarshaller`.

This is an implementation detail that allows unpacking elements inside the action element into the struct in `a.Args`.

type Fault

type Fault struct {
	Code   string      `xml:"faultcode"`
	String string      `xml:"faultstring"`
	Actor  string      `xml:"faultactor"`
	Detail FaultDetail `xml:"detail"`
}

Fault implements error, and contains SOAP fault information.

func (*Fault) Error

func (fe *Fault) Error() string

func (*Fault) Is

func (fe *Fault) Is(target error) bool

type FaultDetail

type FaultDetail struct {
	Raw []byte `xml:",innerxml"`
}

FaultDetail carries XML-encoded application-specific Fault details.

Jump to

Keyboard shortcuts

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