soap

package module
v0.0.0-...-8e36fca Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2015 License: Apache-2.0 Imports: 5 Imported by: 5

README

SOAP XML builder, extracted from github.com/masterzen/winrm/soap and heavily refactored to kill the non-SOAP parts.

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

View Source
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"
)
View Source
const ContentType = "application/soap+xml; charset=utf-8"
View Source
const NS_ENCODING = "http://www.w3.org/2003/05/soap-encoding"
View Source
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

func MuElem(name, space string) *dom.Element

MuElem wraps a call to dom.Elem with a call to MustUnderstand. It is intended to be used as shorthand for generating headers.

func MuElemC

func MuElemC(name, space, content string) *dom.Element

MuElemC wraps a call to dom.ElemC with a call to MustUnderstand. It is intended to be used as shorthand for generating headers.

func MustUnderstand

func MustUnderstand(e *dom.Element) *dom.Element

MustUnderstand ensures that the given element has the mustUnderstand attribute set. WSMAN uses this to cause requests to fail if the endpoint does not know how to process a certian event.

Types

type Message

type Message struct {
	*dom.Document
	// contains filtered or unexported fields
}

Message represents a SOAP message.

func IsSoap

func IsSoap(doc *dom.Document) (res *Message, err error)

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 NewMessage

func NewMessage() *Message

NewMessage creates the skeleton of a new SOAP message.

func Parse

func Parse(r io.Reader) (msg *Message, err error)

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 (m *Message) AllBodyElements() []*dom.Element

func (*Message) AllHeaderElements

func (m *Message) AllHeaderElements() []*dom.Element

func (*Message) Body

func (m *Message) Body() []*dom.Element

Body returns the children of the Body element.

func (*Message) Fault

func (m *Message) Fault() *dom.Element

Fault returns the Fault element if it is present in the SOAP body, otherwise it returns nil.

func (*Message) GetBody

func (m *Message) GetBody(template *dom.Element) *dom.Element

GetBody retrieves the first child of the SOAP body that matches the name and attributes on the passed element.

func (*Message) GetHeader

func (m *Message) GetHeader(template *dom.Element) *dom.Element

GetHeader retrieves the first child of the SOAP header that matches the name and attributes on the passed element.

func (*Message) Headers

func (m *Message) Headers() []*dom.Element

Headers returns the children of the Header element.

func (*Message) RemoveBody

func (m *Message) RemoveBody(elem *dom.Element) *dom.Element

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

func (m *Message) RemoveHeader(elem *dom.Element) *dom.Element

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

func (m *Message) SetBody(elems ...*dom.Element) *Message

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.

func (*Message) SetHeader

func (m *Message) SetHeader(elems ...*dom.Element) *Message

SetHeader adds (or updates) any number of elements to the SOAP header.

Elements that do not exist will be appended to the rest of the headers, and headers that already exist will be replaced in place. The SOAP message is returned.

Jump to

Keyboard shortcuts

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