proxy

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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

View Source
var DefaultOptions = Options{
	Timeout:             30 * time.Second,
	ConnectionTimeout:   90 * time.Second,
	TlsHandshakeTimeout: 15 * time.Second,
}

Functions

func LogXml

func LogXml(logType string, message interface{})

func String added in v1.2.5

func String(v string) *string

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, an auto-generated packageID and no MTOM-usage

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) SetPackageID

func (b *Binary) SetPackageID(packageID string) *Binary

SetPackageID sets and overrides the default auto-generated package ID to be used for the multipart binary

func (*Binary) SetUseMTOM

func (b *Binary) SetUseMTOM(useMTOM bool) *Binary

SetUseMTOM activates the XOP transformation of binaries in MTOM requests

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 - 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) AddMIMEMultipartAttachment

func (s *Client) AddMIMEMultipartAttachment(attachment soap.MIMEMultipartAttachment)

AddMIMEMultipartAttachment adds an attachment to the client that will be sent only if the WithMIMEMultipartAttachments option is used

func (*Client) Call

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

Call performs HTTP POST request. Note that if the server returns a status code >= 400, a HTTPError will be returned

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) CallContextWithAttachmentsAndFaultDetail

func (s *Client) CallContextWithAttachmentsAndFaultDetail(ctx context.Context, soapAction string, request, response interface{}, faultDetail soap.FaultError, attachments *[]soap.MIMEMultipartAttachment) error

CallContextWithAttachmentsAndFaultDetail performs HTTP POST request. Note that if SOAP fault is returned, it will be stored in the error. On top the attachments array will be filled with attachments returned from the SOAP request.

func (*Client) CallContextWithFaultDetail

func (s *Client) CallContextWithFaultDetail(ctx context.Context, soapAction string, request, response interface{}, faultDetail soap.FaultError) error

CallContextWithFaultDetail performs HTTP POST request. Note that if SOAP fault is returned, it will be stored in the error.

func (*Client) CallWithFaultDetail

func (s *Client) CallWithFaultDetail(soapAction string, request, response interface{}, faultDetail soap.FaultError) error

CallWithFaultDetail performs HTTP POST request. Note that if SOAP fault is returned, it will be stored in the error. the passed in fault detail is expected to implement FaultError interface, which allows to condense the detail into a short error message.

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 Credential

type Credential struct {
	Username string
	Password string
}

Credential are used when setting WithBasicAuth or WithNTLM, the latter needs the domain to be set, whereas for basic auth is not needed.

type DomainCredential

type DomainCredential struct {
	Domain string
	Credential
}

type HTTPClient

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

HTTPClient is a client which can make HTTP requests

type Option

type Option func(*Options)

Option allows to customize the default http client or even provide a custom http client.

func WithBasicAuth

func WithBasicAuth(credential *Credential) Option

WithBasicAuth is an Option to set BasicAuth

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient allows to use a custom HTTP client instead of the default.

WithNTLM option, if provided, will replace the http client transport.

WithTLSHandshakeTimeout, WithTLS and/or WithTimeout clientOption will be discarded.

func WithHTTPHeaders

func WithHTTPHeaders(headers map[string]string) Option

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

func WithLogRequests added in v1.2.0

func WithLogRequests(on bool) Option

WithLogRequests sets logging of requests, by default log is disabled

func WithLogResponses added in v1.2.0

func WithLogResponses(on bool) Option

WithLogResponses sets logging of responses, by default log is disabled

func WithMIMEMultipartAttachments

func WithMIMEMultipartAttachments() Option

WithMIMEMultipartAttachments is an Option to set SOAP MIME Multipart attachment support.

Use Client.AddMIMEMultipartAttachment to add attachments of type MIMEMultipartAttachment to your SOAP request.

func WithMTOM

func WithMTOM() Option

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

func WithNTLM

func WithNTLM(credential *DomainCredential) Option

WithNTLM configures for a given http.Client its transport for NTLM, it works with WithTLS which should be called prior to it to set the right tls.Config, if not it will default to a simple tls.Config with InsecureSkipVerify set to true to avoid certs issues This setting will be configured even in the custom httpClient replacing existing transport with this one.

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 context timeout.

type Options

type Options struct {
	Client              HTTPClient
	Transport           *httpntlm.NtlmTransport
	TlsConfig           *tls.Config
	HttpHeaders         map[string]string
	Mtom                bool
	Mma                 bool
	Timeout             time.Duration
	ConnectionTimeout   time.Duration
	TlsHandshakeTimeout time.Duration
	BasicAuth           *Credential
	NtlmAuth            *DomainCredential
	LogRequests         bool
	LogResponses        bool
}

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(credential *Credential, 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