Documentation ¶
Overview ¶
Package soap wraps github.com/VictorLowther/simplexml/dom to provide convienent methods for dealing with SOAP messages as a SOAP client.
Index ¶
- Constants
- func MuElem(name, space string) *dom.Element
- func MuElemC(name, space, content string) *dom.Element
- func MustUnderstand(e *dom.Element) *dom.Element
- type Message
- func (m *Message) AllBodyElements() []*dom.Element
- func (m *Message) AllHeaderElements() []*dom.Element
- func (m *Message) Body() []*dom.Element
- func (m *Message) Fault() *dom.Element
- func (m *Message) GetBody(template *dom.Element) *dom.Element
- func (m *Message) GetHeader(template *dom.Element) *dom.Element
- func (m *Message) Headers() []*dom.Element
- func (m *Message) RemoveBody(elem *dom.Element) *dom.Element
- func (m *Message) RemoveHeader(elem *dom.Element) *dom.Element
- func (m *Message) SetBody(elems ...*dom.Element) *Message
- func (m *Message) SetHeader(elems ...*dom.Element) *Message
Constants ¶
const ( BadEnvelope = "Invalid SOAP: Root should be an Envelope" BadTag = "Invalid SOAP: Unexpected tag in Envelope" EnvelopeOverstuffed = "Invalid SOAP: Envelope must have at most 2 children" NoEnvelope = "Invalid SOAP: Document does not have a root element" TooManyBody = "Invalid SOAP: More than one Body" TooManyHeader = "Invalid SOAP: More than one Header" )
const ContentType = "application/soap+xml; charset=utf-8"
const NS_ENCODING = "http://www.w3.org/2003/05/soap-encoding"
const NS_ENVELOPE = "http://www.w3.org/2003/05/soap-envelope"
Default SOAP namespaces. Taken from appendix 1 of http://www.dmtf.org/sites/default/files/standards/documents/DSP0226_1.2.0.pdf
Variables ¶
This section is empty.
Functions ¶
func MuElem ¶
MuElem wraps a call to dom.Elem with a call to MustUnderstand. It is intended to be used as shorthand for generating headers.
Types ¶
type Message ¶
Message represents a SOAP message.
func IsSoap ¶
IsSoap takes a simplexml dom.Document and validates that it contains a valid SOAP message. If it does, it returns a Message. If it does not, it returns an error explaining why not.
func Parse ¶
Parse parses what is hopefully a well-formed SOAP message from the passed io.Reader. If it is not, err will say why not.
func (*Message) AllBodyElements ¶
func (*Message) AllHeaderElements ¶
func (*Message) Fault ¶
Fault returns the Fault element if it is present in the SOAP body, otherwise it returns nil.
func (*Message) GetBody ¶
GetBody retrieves the first child of the SOAP body that matches the name and attributes on the passed element.
func (*Message) GetHeader ¶
GetHeader retrieves the first child of the SOAP header that matches the name and attributes on the passed element.
func (*Message) RemoveBody ¶
RemoveBody removes an element from the SOAP Body. If the element was not a child of the SOAP body, nil is returned, otherwise the element is returned.
func (*Message) RemoveHeader ¶
RemoveHeader removes an element from the SOAP Header. If the element was not a header, nil is returned, otherwise the element is returned.
func (*Message) SetBody ¶
SetBody adds (or updates) any number of elements to the SOAP header.
Elements that do not exist will be appended to the rest of the body, and ones that already exist will be replaced in place. The SOAP message is returned.