client

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: 9 Imported by: 0

Documentation

Overview

Package client provides a basic SOAP client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSOAP can be used with errors.Is.
	ErrSOAP = errors.New("SOAP error")
)

Functions

func ParseResponseAction

func ParseResponseAction(
	resp *http.Response,
	actionOut *envelope.Action,
) error

ParseResponse extracts a parsed action from an HTTP response. The caller is responsible for calling resp.Body.Close(), but this function will consume the entire response body.

func PerformAction

func PerformAction(
	ctx context.Context, c *Client,
	action soap.Action,
) error

PerformAction makes a SOAP request, with the given action.

This is a convenience for calling `Client.Do` without creating `*envelope.Action` values.

func SetRequestAction

func SetRequestAction(
	req *http.Request,
	actionIn *envelope.Action,
) error

SetRequestAction updates fields in `req` with the given SOAP action. Specifically it sets Body, ContentLength, Method, and the SOAPACTION and CONTENT-TYPE headers.

Types

type Client

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

Client is a SOAP client, attached to a specific SOAP endpoint. the zero value is not usable, use NewClient() to create an instance.

func New

func New(endpointURL string, opts ...Option) *Client

New creates a new SOAP client, which will POST its requests to the given URL.

func (*Client) Do

func (c *Client) Do(
	ctx context.Context,
	actionIn, actionOut *envelope.Action,
) error

PerformAction makes a SOAP request, with the given action values to provide arguments (`args`) and capture the `reply` into.

type HTTPClient

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

HTTPClient defines the interface required of an HTTP client. It is a subset of *http.Client.

type Option

type Option func(*options)

Option is the type for optional configuration of a Client.

func WithHTTPClient

func WithHTTPClient(httpClient HTTPClient) Option

WithHTTPClient specifies an *http.Client to use instead of http.DefaultClient.

type SOAPError

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

SOAPError describes an error from this package, potentially including a lower-level cause.

func (*SOAPError) Error

func (se *SOAPError) Error() string

func (*SOAPError) Is

func (se *SOAPError) Is(target error) bool

func (*SOAPError) Unwrap

func (se *SOAPError) Unwrap() error

Jump to

Keyboard shortcuts

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