1package soap
2
3import (
4	"encoding/xml"
5)
6
7const (
8	EncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
9	EnvelopeNS    = "http://schemas.xmlsoap.org/soap/envelope/"
10)
11
12type Arg struct {
13	XMLName xml.Name
14	Value   string `xml:",chardata"`
15}
16
17type Action struct {
18	XMLName xml.Name
19	Args    []Arg
20}
21
22type Body struct {
23	Action []byte `xml:",innerxml"`
24}
25
26type UPnPError struct {
27	XMLName xml.Name `xml:"urn:schemas-upnp-org:control-1-0 UPnPError"`
28	Code    uint     `xml:"errorCode"`
29	Desc    string   `xml:"errorDescription"`
30}
31
32type FaultDetail struct {
33	XMLName xml.Name `xml:"detail"`
34	Data    interface{}
35}
36
37type Fault struct {
38	XMLName     xml.Name    `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
39	FaultCode   string      `xml:"faultcode"`
40	FaultString string      `xml:"faultstring"`
41	Detail      FaultDetail `xml:"detail"`
42}
43
44func NewFault(s string, detail interface{}) *Fault {
45	return &Fault{
46		FaultCode:   EnvelopeNS + ":Client",
47		FaultString: s,
48		Detail: FaultDetail{
49			Data: detail,
50		},
51	}
52}
53
54type Envelope struct {
55	XMLName       xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
56	EncodingStyle string   `xml:"encodingStyle,attr"`
57	Body          Body     `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
58}
59
60/* XML marshalling of nested namespaces is broken.
61
62func NewEnvelope(action []byte) Envelope {
63	return Envelope{
64		EncodingStyle: EncodingStyle,
65		Body:          Body{action},
66	}
67}
68*/
69