Documentation
¶
Overview ¶
Package soap provides transport-neutral SOAP 1.1 and SOAP 1.2 envelope, body, and fault primitives while preserving access to the original XML.
Index ¶
- Constants
- Variables
- func Encode(version Version, header, body any, options EncodeOptions) ([]byte, error)
- func EncodeWriter(writer io.Writer, version Version, header, body any, options EncodeOptions) error
- func Marshal(version Version, header, body []byte) ([]byte, error)
- func MarshalFault(fault Fault) ([]byte, error)
- func MarshalFaultWithOptions(fault Fault, options MarshalOptions) ([]byte, error)
- func MarshalFaultWriter(writer io.Writer, fault Fault) error
- func MarshalFaultWriterWithOptions(writer io.Writer, fault Fault, options MarshalOptions) error
- func MarshalWithOptions(version Version, header, body []byte, options MarshalOptions) ([]byte, error)
- func MarshalWriter(writer io.Writer, version Version, header, body []byte) error
- func MarshalWriterWithOptions(writer io.Writer, version Version, header, body []byte, options MarshalOptions) error
- type EncodeOptions
- type Envelope
- type Fault
- type FaultError
- type FaultReason
- type MarshalOptions
- type ParseOptions
- type Version
Constants ¶
const DefaultMaxBytes int64 = 1 << 20
DefaultMaxBytes is the default maximum SOAP envelope size.
Variables ¶
var ErrPayloadTooLarge = errors.New("payload exceeds size limit")
ErrPayloadTooLarge identifies SOAP output that exceeds the configured limit.
Functions ¶
func Encode ¶
func Encode(version Version, header, body any, options EncodeOptions) ([]byte, error)
Encode serializes typed header and body values as XML and wraps them in a SOAP envelope. A nil header is omitted and a nil body emits an empty Body.
func EncodeWriter ¶
EncodeWriter serializes typed SOAP values and writes the complete envelope to writer.
func Marshal ¶
Marshal creates a deterministic SOAP envelope around validated raw header and body fragments.
func MarshalFault ¶
MarshalFault validates and serializes a SOAP fault envelope.
func MarshalFaultWithOptions ¶
func MarshalFaultWithOptions(fault Fault, options MarshalOptions) ([]byte, error)
MarshalFaultWithOptions validates and serializes a size-bounded SOAP fault envelope.
func MarshalFaultWriter ¶
MarshalFaultWriter serializes a SOAP fault and writes the complete envelope to writer.
func MarshalFaultWriterWithOptions ¶
func MarshalFaultWriterWithOptions(writer io.Writer, fault Fault, options MarshalOptions) error
MarshalFaultWriterWithOptions serializes a size-bounded SOAP fault and writes it only after serialization succeeds.
func MarshalWithOptions ¶
func MarshalWithOptions(version Version, header, body []byte, options MarshalOptions) ([]byte, error)
MarshalWithOptions creates a deterministic, size-bounded SOAP envelope around validated raw header and body fragments.
func MarshalWriter ¶
MarshalWriter creates a SOAP envelope around raw fragments and writes it to writer.
func MarshalWriterWithOptions ¶
func MarshalWriterWithOptions(writer io.Writer, version Version, header, body []byte, options MarshalOptions) error
MarshalWriterWithOptions creates a size-bounded SOAP envelope and writes it to writer only after serialization succeeds.
Types ¶
type EncodeOptions ¶
EncodeOptions controls XML serialization for typed SOAP header and body values.
type Envelope ¶
Envelope is a validated SOAP envelope with preserved raw sections.
func Parse ¶
func Parse(payload []byte, options ParseOptions) (*Envelope, error)
Parse validates and extracts a SOAP envelope. Valid SOAP faults return both the envelope and a *FaultError.
func ParseReader ¶
func ParseReader(reader io.Reader, options ParseOptions) (*Envelope, error)
ParseReader reads a bounded stream and parses a SOAP envelope.
func (*Envelope) DecodeBody ¶
DecodeBody decodes the single body child while retaining namespace bindings declared on the source envelope.
type Fault ¶
type Fault struct {
Version Version
Code string
Subcodes []string
Reason string
Reasons []FaultReason
Actor string
Node string
Role string
Detail []byte
Raw []byte
}
Fault is a version-neutral representation of SOAP 1.1 and 1.2 faults.
type FaultError ¶
type FaultError struct {
Fault Fault
}
FaultError reports a valid SOAP fault response.
func (*FaultError) Error ¶
func (e *FaultError) Error() string
func (*FaultError) Unwrap ¶
func (e *FaultError) Unwrap() error
Unwrap exposes the shared SOAP-fault classification.
type FaultReason ¶
FaultReason is one localized SOAP 1.2 fault reason.
type MarshalOptions ¶
type MarshalOptions struct {
MaxBytes int64
}
MarshalOptions controls raw SOAP envelope and fault serialization.