soap

package
v0.0.0-...-7430e72 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Predefined WSS namespaces to be used in
	WssNsWSSE string = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
	WssNsWSU  string = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
	WssNsType string = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Binary

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

Binary enables binary data to be enchanged in MTOM mode with XOP encoding When MTOM is not used, the field is encoded in Base64

func NewBinary

func NewBinary(v []byte) *Binary

NewBinary allocate a new Binary backed by the given byte slice

func (*Binary) Bytes

func (b *Binary) Bytes() []byte

Bytes returns a slice backed by the content of the field

func (*Binary) ContentType

func (b *Binary) ContentType() string

ContentType returns the content type

func (*Binary) MarshalXML

func (b *Binary) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface to encode a Binary to XML

func (*Binary) SetContentType

func (b *Binary) SetContentType(contentType string) *Binary

SetContentType sets the content type the content will be transmitted as multipart

func (*Binary) UnmarshalXML

func (b *Binary) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface to decode a Binary form XML

type Client

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

Client is soap client

func NewClient

func NewClient(url string, opt ...Option) *Client

NewClient creates new SOAP client instance

func (*Client) AddHeader

func (s *Client) AddHeader(header interface{})

AddHeader adds envelope header For correct behavior, every header must contain a `XMLName` field. Refer to #121 for details

func (*Client) Call

func (s *Client) Call(soapAction string, request, response interface{}) error

Call performs HTTP POST request

func (*Client) CallContext

func (s *Client) CallContext(ctx context.Context, soapAction string, request, response interface{}) error

CallContext performs HTTP POST request with a context

func (*Client) SetHeaders

func (s *Client) SetHeaders(headers ...interface{})

SetHeaders sets envelope headers, overwriting any existing headers. For correct behavior, every header must contain a `XMLName` field. Refer to #121 for details

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is a client which can make HTTP requests An example implementation is net/http.Client

type Option

type Option func(*options)

A Option sets options such as credentials, tls, etc.

func WithBasicAuth

func WithBasicAuth(login, password string) Option

WithBasicAuth is an Option to set BasicAuth

func WithHTTPClient

func WithHTTPClient(c HTTPClient) Option

WithHTTPClient is an Option to set the HTTP client to use This cannot be used with WithTLSHandshakeTimeout, WithTLS, WithTimeout options

func WithHTTPHeaders

func WithHTTPHeaders(headers map[string]string) Option

WithHTTPHeaders is an Option to set global HTTP headers for all requests

func WithMTOM

func WithMTOM() Option

WithMTOM is an Option to set Message Transmission Optimization Mechanism MTOM encodes fields of type Binary using XOP.

func WithRequestTimeout

func WithRequestTimeout(t time.Duration) Option

WithRequestTimeout is an Option to set default end-end connection timeout This option cannot be used with WithHTTPClient

func WithTLS

func WithTLS(tls *tls.Config) Option

WithTLS is an Option to set tls config This option cannot be used with WithHTTPClient

func WithTLSHandshakeTimeout

func WithTLSHandshakeTimeout(t time.Duration) Option

WithTLSHandshakeTimeout is an Option to set default tls handshake timeout This option cannot be used with WithHTTPClient

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout is an Option to set default HTTP dial timeout

type SOAPBody

type SOAPBody struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`

	Fault   *SOAPFault  `xml:",omitempty"`
	Content interface{} `xml:",omitempty"`
}

func (*SOAPBody) UnmarshalXML

func (b *SOAPBody) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error

UnmarshalXML unmarshals SOAPBody xml

type SOAPDecoder

type SOAPDecoder interface {
	Decode(v interface{}) error
}

type SOAPEncoder

type SOAPEncoder interface {
	Encode(v interface{}) error
	Flush() error
}

type SOAPEnvelope

type SOAPEnvelope struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
	Header  *SOAPHeader
	Body    SOAPBody
}

type SOAPFault

type SOAPFault struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`

	Code   string `xml:"faultcode,omitempty"`
	String string `xml:"faultstring,omitempty"`
	Actor  string `xml:"faultactor,omitempty"`
	Detail string `xml:"detail,omitempty"`
}

func (*SOAPFault) Error

func (f *SOAPFault) Error() string

type SOAPHeader

type SOAPHeader struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"`

	Headers []interface{}
}

type WSSPassword

type WSSPassword struct {
	XMLName   xml.Name `xml:"wsse:Password"`
	XmlNSWsse string   `xml:"xmlns:wsse,attr"`
	XmlNSType string   `xml:"Type,attr"`

	Data string `xml:",chardata"`
}

type WSSSecurityHeader

type WSSSecurityHeader struct {
	XMLName   xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ wsse:Security"`
	XmlNSWsse string   `xml:"xmlns:wsse,attr"`

	MustUnderstand string `xml:"mustUnderstand,attr,omitempty"`

	Token *WSSUsernameToken `xml:",omitempty"`
}

func NewWSSSecurityHeader

func NewWSSSecurityHeader(user, pass, tokenID, mustUnderstand string) *WSSSecurityHeader

NewWSSSecurityHeader creates WSSSecurityHeader instance

type WSSUsername

type WSSUsername struct {
	XMLName   xml.Name `xml:"wsse:Username"`
	XmlNSWsse string   `xml:"xmlns:wsse,attr"`

	Data string `xml:",chardata"`
}

type WSSUsernameToken

type WSSUsernameToken struct {
	XMLName   xml.Name `xml:"wsse:UsernameToken"`
	XmlNSWsu  string   `xml:"xmlns:wsu,attr"`
	XmlNSWsse string   `xml:"xmlns:wsse,attr"`

	Id string `xml:"wsu:Id,attr,omitempty"`

	Username *WSSUsername `xml:",omitempty"`
	Password *WSSPassword `xml:",omitempty"`
}

Jump to

Keyboard shortcuts

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