soap

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: MPL-2.0 Imports: 18 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 Header)

AddHeader adds envelope header

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

type Envelope

type Envelope interface {
	AddAction(soapAction string)
	SetHeader(header Header)
	AddContent(content interface{})
	GetFault() error
}

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 Header interface {
	SetAction(action string)
	SetContent(content interface{})
}

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 WithCustomRequest added in v1.0.0

func WithCustomRequest(e Envelope) Option

With Custom Envelope Request is an option for customizing the Envelope.

func WithCustomResponse added in v1.0.0

func WithCustomResponse(e Envelope) Option

With Custom Envelope Response is an option for customizing the Envelope.

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   error       `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
	DecodeElement(v interface{}, start *xml.StartElement) 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  Header   `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"`
	Body    SOAPBody
}

func (*SOAPEnvelope) AddAction added in v1.0.1

func (s *SOAPEnvelope) AddAction(soapAction string)

func (*SOAPEnvelope) AddContent

func (s *SOAPEnvelope) AddContent(content interface{})

func (*SOAPEnvelope) GetFault

func (s *SOAPEnvelope) GetFault() error

func (*SOAPEnvelope) SetHeader added in v1.0.1

func (s *SOAPEnvelope) SetHeader(header Header)

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"`
	To      *SOAPHeaderTo
	Action  *SOAPHeaderAction
	Content interface{} `xml:",omitempty"`
}

func (*SOAPHeader) SetAction added in v1.0.1

func (h *SOAPHeader) SetAction(action string)

func (*SOAPHeader) SetContent

func (h *SOAPHeader) SetContent(content interface{})

type SOAPHeaderAction added in v1.0.1

type SOAPHeaderAction struct {
	XMLName xml.Name `xml:"Action"`
	Data    string   `xml:",chardata"`
}

type SOAPHeaderTo added in v1.0.1

type SOAPHeaderTo struct {
	XMLName        xml.Name `xml:"To"`
	MustUnderstand string   `xml:"mustUnderstand,attr,omitempty"`
	Data           string   `xml:",chardata"`
}

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