Esempio n. 1
0
func NewMessage() (message *SoapMessage) {
	doc := dom.CreateDocument()
	e := dom.CreateElement("Envelope")
	doc.SetRoot(e)
	AddUsualNamespaces(e)
	NS_SOAP_ENV.SetTo(e)

	message = &SoapMessage{document: doc, envelope: e}
	return
}
Esempio n. 2
0
func TestSetTo(t *testing.T) {
	doc := dom.CreateDocument()
	root := dom.CreateElement("root")
	doc.SetRoot(root)
	NS_SOAP_ENV.SetTo(root)

	if root.String() != `<env:root xmlns:env="http://www.w3.org/2003/05/soap-envelope"/>` {
		t.Errorf("Test failed - root has not the correct NS: %s", root.String())
	}
}
Esempio n. 3
0
func initDocument() (h *SoapHeader) {
	doc := dom.CreateDocument()
	doc.PrettyPrint = true
	e := dom.CreateElement("Envelope")
	doc.SetRoot(e)
	AddUsualNamespaces(e)
	NS_SOAP_ENV.SetTo(e)
	h = &SoapHeader{message: &SoapMessage{document: doc, envelope: e}}
	return
}
Esempio n. 4
0
func TestAddUsualNamespaces(t *testing.T) {
	doc := dom.CreateDocument()
	root := dom.CreateElement("root")
	doc.SetRoot(root)
	AddUsualNamespaces(root)

	for ns := range root.DeclaredNamespaces() {
		found := false
		for ns2 := range MostUsed {
			if ns2 == ns {
				found = true
			}
		}
		if !found {
			t.Errorf("Test failed - Namespace %s not found", ns)
		}
	}

}
Esempio n. 5
0
func (self *SoapHeader) createElement(parent *dom.Element, name string, ns dom.Namespace) (element *dom.Element) {
	element = dom.CreateElement(name)
	parent.AddChild(element)
	ns.SetTo(element)
	return
}
Esempio n. 6
0
func (message *SoapMessage) CreateElement(parent *dom.Element, name string, ns dom.Namespace) (element *dom.Element) {
	element = dom.CreateElement(name)
	parent.AddChild(element)
	ns.SetTo(element)
	return
}
Esempio n. 7
0
func (message *SoapMessage) NewBody() (body *dom.Element) {
	body = dom.CreateElement("Body")
	message.envelope.AddChild(body)
	NS_SOAP_ENV.SetTo(body)
	return
}