File: soap.go

package info (click to toggle)
golang-github-anacrolix-dms 1.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 436 kB
  • sloc: xml: 19; sh: 19; makefile: 9
file content (68 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package soap

import (
	"encoding/xml"
)

const (
	EncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
	EnvelopeNS    = "http://schemas.xmlsoap.org/soap/envelope/"
)

type Arg struct {
	XMLName xml.Name
	Value   string `xml:",chardata"`
}

type Action struct {
	XMLName xml.Name
	Args    []Arg
}

type Body struct {
	Action []byte `xml:",innerxml"`
}

type UPnPError struct {
	XMLName xml.Name `xml:"urn:schemas-upnp-org:control-1-0 UPnPError"`
	Code    uint     `xml:"errorCode"`
	Desc    string   `xml:"errorDescription"`
}

type FaultDetail struct {
	XMLName xml.Name `xml:"detail"`
	Data    interface{}
}

type Fault struct {
	XMLName     xml.Name    `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
	FaultCode   string      `xml:"faultcode"`
	FaultString string      `xml:"faultstring"`
	Detail      FaultDetail `xml:"detail"`
}

func NewFault(s string, detail interface{}) *Fault {
	return &Fault{
		FaultCode:   EnvelopeNS + ":Client",
		FaultString: s,
		Detail: FaultDetail{
			Data: detail,
		},
	}
}

type Envelope struct {
	XMLName       xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
	EncodingStyle string   `xml:"encodingStyle,attr"`
	Body          Body     `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
}

/* XML marshalling of nested namespaces is broken.

func NewEnvelope(action []byte) Envelope {
	return Envelope{
		EncodingStyle: EncodingStyle,
		Body:          Body{action},
	}
}
*/