-
Notifications
You must be signed in to change notification settings - Fork 1
/
invoke.go
41 lines (35 loc) · 852 Bytes
/
invoke.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package wsman
import (
"encoding/xml"
"log"
"strings"
"github.com/runner-mei/wsman/envelope"
)
func Invoke(ep *Endpoint, ns, name string, selectorSet map[string]string,
method string, inParameters map[string]interface{}) (map[string]interface{}, error) {
input := &envelope.InvokeMethod{
Namespace: ns,
MessageId: Uuid(),
Name: name,
SelectorSet: selectorSet,
Method: method,
InParameters: inParameters,
}
reader, err := ep.Deliver(strings.NewReader(input.Xml()))
if nil != err {
return nil, err
}
defer closeReader(reader)
decoder := xml.NewDecoder(reader)
if err = ReadEnvelopeBody(decoder); nil != err {
return nil, err
}
tagName, _, err := nextElement(decoder)
if nil != err {
return nil, err
}
if tagName.Local != method+"_OUTPUT" {
log.Println(tagName)
}
return toMap(decoder)
}