soap

package module
v0.0.0-...-076ae08 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 10 Imported by: 0

README

soap

Bridgevine/soap is a foundation for SOAP based communications.

Read the SOAP version 1.1 and 1.2 documentations here: http://www.w3.org/TR/soap/

Documentation

Overview

Package soap ... TO BE ADDED

Index

Constants

View Source
const (
	V11 string = "1.1"
	V12 string = "1.2"
)

Constants to represent the different SOAP versions.

Variables

View Source
var ErrInvalidVersion = errors.New("version must be either 1.1 or 1.2")

ErrInvalidVersion is an error returned when the specified version is not one of the allowed versions.

Functions

This section is empty.

Types

type Body

type Body interface {
	Fault() Fault
	Payload() []byte
}

Body represents behaviors supported by the Body element of a SOAP Envelope.

type Body11

type Body11 struct {
	FaultElem   *Fault11 `xml:"Fault,omitempty"`
	PayloadElem []byte   `xml:",innerxml"`
}

Body11 models the body element of the SOAP 1.1 Envelope.

func (*Body11) Fault

func (b *Body11) Fault() Fault

Fault returns the fault element contained in the body element of a SOAP 1.1 Envelope, if present.

func (*Body11) Payload

func (b *Body11) Payload() []byte

Payload returns the payload contained in the body element of a SOAP 1.1 Envelope.

type Body12

type Body12 struct {
	FaultElem   *Fault12 `xml:"Fault,omitempty"`
	PayloadElem []byte   `xml:",innerxml"`
}

Body12 models the body element of the SOAP 1.2 Envelope.

func (*Body12) Fault

func (b *Body12) Fault() Fault

Fault returns the fault element contained in the body element of a SOAP 1.2 Envelope, if present.

func (*Body12) Payload

func (b *Body12) Payload() []byte

Payload returns the payload contained in the body element of a SOAP 1.2 Envelope.

type Client

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

Client represents a SOAP client that will be used to send requests and process responses.

func NewClient

func NewClient(url string, opts ...Option) (*Client, error)

NewClient creates a new SOAP client and set its initial state. The url parameter represents the SOAP Service URL.

func (*Client) Do

func (c *Client) Do(req *Request) (*Response, error)

Do sends a SOAP request.

type Code

type Code struct {
	Value   string   `xml:"Value"`
	Subcode *Subcode `xml:"Subcode,omitempty"`
}

Code models the SOAP 1.2 code element. Specifications can be found at http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#faultcodeelement.

type EnvBuilder

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

EnvBuilder is a SOAP Envelope builder.

func NewEnvBuilder

func NewEnvBuilder() *EnvBuilder

NewEnvBuilder returns a new Envelope builder.

func (*EnvBuilder) Build

func (bldr *EnvBuilder) Build(version string) (Envelope, error)

Build builds an Envelope for the specified SOAP version.

func (*EnvBuilder) BuildHTTPRequest

func (bldr *EnvBuilder) BuildHTTPRequest(version string, action string) (*http.Request, error)

BuildHTTPRequest builds a HTTP Request.

func (*EnvBuilder) Env

func (bldr *EnvBuilder) Env() Envelope

Env will return the latest envelope built with this builder. If neither Build nor BuildHTTPRequest has been called successfully, nil will be returned.

func (*EnvBuilder) SetHeaders

func (bldr *EnvBuilder) SetHeaders(hdrs ...interface{}) *EnvBuilder

SetHeaders sets the SOAP headers, overriding the previous ones.

func (*EnvBuilder) SetPayload

func (bldr *EnvBuilder) SetPayload(items ...interface{}) *EnvBuilder

SetPayload sets the payload, overriding the previous one.

type EnvBuilderOption

type EnvBuilderOption func(*EnvBuilder)

EnvBuilderOption represents a configuration function for an EnvBuilder. An Option will configure or set up internal details of an EnvBuilder.

func SetXmlns

func SetXmlns(xmlns map[string]string) EnvBuilderOption

SetXmlns returns a configuration function to configure the namespace prefix of an EnvBuilderOption.

type Envelope

type Envelope interface {
	Header() *Header
	Body() Body
	GetHTTPRequest(action string) (*http.Request, error)
	// contains filtered or unexported methods
}

Envelope represents behaviors supported by a SOAP Envelope.

func DecodeEnvelope

func DecodeEnvelope(version string, r io.Reader) (Envelope, error)

DecodeEnvelope decodes the specified io.Reader into an Envelope of the specified version.

func NewEnvelope

func NewEnvelope(version string, header interface{}, payload interface{}, opts ...EnvBuilderOption) (Envelope, error)

NewEnvelope returns a new Envelope based on the parameters passed.

type Envelope11

type Envelope11 struct {
	XMLName    xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
	Xmlns      map[string]string
	HeaderElem *Header `xml:"Header,omitempty"`
	BodyElem   Body11  `xml:"Body"`
}

Envelope11 models an envelope following the SOAP 1.1 Envelope specs.

func (*Envelope11) Body

func (e *Envelope11) Body() Body

Body implements the Body method of the Envelope interface.

func (*Envelope11) GetHTTPRequest

func (e *Envelope11) GetHTTPRequest(action string) (*http.Request, error)

GetHTTPRequest TODO.

func (*Envelope11) Header

func (e *Envelope11) Header() *Header

Header implements the Header method of the Envelope interface.

func (Envelope11) MarshalXML

func (x Envelope11) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Envelope12

type Envelope12 struct {
	XMLName    xml.Name `xml:"http://www.w3.org/2003/05/soap-envelope Envelope"`
	Xmlns      map[string]string
	HeaderElem *Header `xml:"Header,omitempty"`
	BodyElem   Body12  `xml:"Body"`
}

Envelope12 models an envelope following the SOAP 1.2 Envelope specs.

func (*Envelope12) Body

func (e *Envelope12) Body() Body

Body implements the Body method of the Envelope interface.

func (*Envelope12) GetHTTPRequest

func (e *Envelope12) GetHTTPRequest(action string) (*http.Request, error)

GetHTTPRequest TODO.

func (*Envelope12) Header

func (e *Envelope12) Header() *Header

Header implements the Header method of the Envelope interface.

func (*Envelope12) MarshalXML

func (e *Envelope12) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

MarshalXML sets the SOAP 1.2 namespace and calls the generic envelope XML marshaller.

type Fault

type Fault interface {
	GetCode() string
	Description() string
	Details() []byte
}

Fault represents behaviors supported by a Fault.

type Fault11

type Fault11 struct {
	XMLName xml.Name     `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
	Code    string       `xml:"faultcode"`
	String  string       `xml:"faultstring"`
	Actor   string       `xml:"faultactor,omitempty"`
	Detail  *FaultDetail `xml:"detail,omitempty"`
}

Fault11 models a fault under SOAP 1.1.

func (*Fault11) Description

func (f *Fault11) Description() string

Description implements the Description method of the Fault interface.

func (*Fault11) Details

func (f *Fault11) Details() []byte

Details implements the Details method of the Fault interface.

func (*Fault11) GetCode

func (f *Fault11) GetCode() string

GetCode implements the GetCode method of the Fault interface.

type Fault12

type Fault12 struct {
	XMLName xml.Name     `xml:"http://www.w3.org/2003/05/soap-envelope Fault"`
	Code    Code         `xml:"Code"`
	Reason  Reason       `xml:"Reason"`
	Node    string       `xml:"Node,omitempty"`
	Role    string       `xml:"Role,omitempty"`
	Detail  *FaultDetail `xml:"Detail,omitempty"`
}

Fault12 models a fault under SOAP 1.2.

func (*Fault12) Description

func (f *Fault12) Description() string

Description implements the Description method of the Fault interface.

func (*Fault12) Details

func (f *Fault12) Details() []byte

Details implements the Details method of the Fault interface.

func (*Fault12) GetCode

func (f *Fault12) GetCode() string

GetCode implements the GetCode method of the Fault interface.

type FaultDetail

type FaultDetail struct {
	Items []byte `xml:",innerxml"`
}

FaultDetail is a container for carrying application specific error information about errors occurred on the endpoint that we will be communicating with. The type of the errors is not known until the response is received, that is why the Items property is an slice of interface{}.

type FaultDetails2

type FaultDetails2 struct {
	Message       string `xml:"message"`
	SOAPErrorCode string `xml:"soapErrorCode"`
}

FaultDetails2 represents the content of Body.Fault.Details() field.

type Header struct {
	Content []byte `xml:",innerxml"`
}

Header models the header section of the SOAP Envelope.

type Option

type Option func(*Client)

Option represents a configuration function for a SOAP client. An option will configure or set up internal details of a SOAP client.

func SetHTTPClient

func SetHTTPClient(httpClient soap_http.ClientAdapter) Option

SetHTTPClient returns a configuration function to configure the HTTP Client that will be used to send the requests.

type Reason

type Reason struct {
	Items []Text `xml:"Text"`
}

Reason models the SOAP 1.2 reason element. The Reason element information item is intended to provide a human readable explanation of the fault. Specifications can be found at http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#faultstringelement.

type Request

type Request struct {
	Env         Envelope
	HTTPHeaders http.Header
	CreatedAt   time.Time
	SentAt      time.Time
}

Request represents a SOAP request.

func NewRequest

func NewRequest(action string, env Envelope) *Request

NewRequest TODO.

type Response

type Response struct {
	Env        Envelope
	Request    *Request
	ReceivedAt time.Time
	URL        string // URL that sent the response.
	Endpoint   string // An endpoint called by request.
	Method     string // A HTTP method used to contact the endpoint.
	StatusCode int    // HTTP status code received
	Payload    string // used when there is an error to strinify the body response
}

Response represents a SOAP response.

type Subcode

type Subcode struct {
	Value   string   `xml:"Value"`
	Subcode *Subcode `xml:"Subcode,omitempty"`
}

Subcode models the SOAP 1.2 subcode element. Specifications can be found at http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#faultsubcodeelement.

type Text

type Text struct {
	Language string `xml:"lang,attr"`
	Value    string `xml:",chardata"`
}

Text models the SOAP 1.2 text element. The Text element information item is intended to carry the text of a human readable explanation of the fault. Specifications can be found at http://www.w3.org/TR/2003/REC-soap12-part1-20030624/#reasontextelement.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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