mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-05 21:11:02 +02:00
Split responses into templates
This commit is contained in:
parent
ce7afd94ec
commit
9088111c4e
78
ecs.go
78
ecs.go
@ -56,28 +56,14 @@ func ecsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(CDS)
|
fmt.Println(CDS)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<Balance>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<CheckDeviceStatusResponse xmlns="urn:ecs.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<Balance>
|
|
||||||
<Amount>2018</Amount>
|
<Amount>2018</Amount>
|
||||||
<Currency>POINTS</Currency>
|
<Currency>POINTS</Currency>
|
||||||
</Balance>
|
</Balance>
|
||||||
<ForceSyncTime>0</ForceSyncTime>
|
<ForceSyncTime>0</ForceSyncTime>
|
||||||
<ExtTicketTime>%s</ExtTicketTime>
|
<ExtTicketTime>%s</ExtTicketTime>
|
||||||
<SyncTime>%s</SyncTime>
|
<SyncTime>%s</SyncTime>`, timestamp, timestamp)
|
||||||
</CheckDeviceStatusResponse>
|
fmt.Fprint(w, formatSuccess("ecs", action, CDS.Version, CDS.DeviceID, CDS.MessageID, custom))
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, CDS.Version, CDS.DeviceID, CDS.MessageID, timestamp, timestamp, timestamp)
|
|
||||||
|
|
||||||
case "NotifiedETicketsSynced":
|
case "NotifiedETicketsSynced":
|
||||||
fmt.Println("NETS")
|
fmt.Println("NETS")
|
||||||
@ -90,21 +76,7 @@ func ecsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(NETS)
|
fmt.Println(NETS)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
fmt.Fprint(w, formatSuccess("ecs", action, NETS.Version, NETS.DeviceID, NETS.MessageID, ""))
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<NotifyETicketsSyncedResponse xmlns="urn:ecs.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
</NotifyETicketsSyncedResponse>
|
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, NETS.Version, NETS.DeviceID, NETS.MessageID, timestamp)
|
|
||||||
|
|
||||||
case "ListETickets":
|
case "ListETickets":
|
||||||
fmt.Println("LET")
|
fmt.Println("LET")
|
||||||
@ -117,24 +89,10 @@ func ecsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(LET)
|
fmt.Println(LET)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<ForceSyncTime>0</ForceSyncTime>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<ListETicketsResponse xmlns="urn:ecs.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<ForceSyncTime>0</ForceSyncTime>
|
|
||||||
<ExtTicketTime>%s</ExtTicketTime>
|
<ExtTicketTime>%s</ExtTicketTime>
|
||||||
<SyncTime>%s</SyncTime>
|
<SyncTime>%s</SyncTime>`, timestamp, timestamp)
|
||||||
</ListETicketsResponse>
|
fmt.Fprint(w, formatSuccess("ecs", action, LET.Version, LET.DeviceID, LET.MessageID, custom))
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, LET.Version, LET.DeviceID, LET.MessageID, timestamp, timestamp, timestamp)
|
|
||||||
|
|
||||||
case "PurchaseTitle":
|
case "PurchaseTitle":
|
||||||
fmt.Println("PT")
|
fmt.Println("PT")
|
||||||
@ -147,19 +105,7 @@ func ecsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(PT)
|
fmt.Println(PT)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<Balance>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<PurchaseTitleResponse xmlns="urn:ecs.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<Balance>
|
|
||||||
<Amount>2018</Amount>
|
<Amount>2018</Amount>
|
||||||
<Currency>POINTS</Currency>
|
<Currency>POINTS</Currency>
|
||||||
</Balance>
|
</Balance>
|
||||||
@ -172,13 +118,11 @@ func ecsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
<ETickets>00000000</ETickets>
|
<ETickets>00000000</ETickets>
|
||||||
<Certs>00000000</Certs>
|
<Certs>00000000</Certs>
|
||||||
<Certs>00000000</Certs>
|
<Certs>00000000</Certs>
|
||||||
<TitleId>00000000</TitleId>
|
<TitleId>00000000</TitleId>`, timestamp, timestamp)
|
||||||
</PurchaseTitleResponse>
|
fmt.Fprint(w, formatSuccess("ecs", action, PT.Version, PT.DeviceID, PT.MessageID, custom))
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, PT.Version, PT.DeviceID, PT.MessageID, timestamp, timestamp, timestamp)
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(w, "WiiSOAP can't handle this. Try again later or actually use a Wii instead of a computer.")
|
fmt.Fprint(w, "WiiSOAP can't handle this. Try again later or actually use a Wii instead of a computer.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
82
ias.go
82
ias.go
@ -22,8 +22,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func iasHandler(w http.ResponseWriter, r *http.Request) {
|
func iasHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -31,10 +29,6 @@ func iasHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
action := r.Header.Get("SOAPAction")
|
action := r.Header.Get("SOAPAction")
|
||||||
action = parseAction(action, "ias")
|
action = parseAction(action, "ias")
|
||||||
|
|
||||||
// Get a sexy new timestamp to use.
|
|
||||||
timestampNano := strconv.FormatInt(time.Now().UTC().Unix(), 10)
|
|
||||||
timestamp := timestampNano + "000"
|
|
||||||
|
|
||||||
fmt.Println("[!] Incoming IAS request.")
|
fmt.Println("[!] Incoming IAS request.")
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -57,23 +51,9 @@ func iasHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(CR)
|
fmt.Println(CR)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<OriginalSerialNumber>%s</OriginalSerialNumber>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
<DeviceStatus>R</DeviceStatus>`, CR.SerialNo)
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
fmt.Fprint(w, formatSuccess("ias", action, CR.Version, CR.DeviceID, CR.MessageID, custom))
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<CheckRegistrationResponse xmlns="urn:ias.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<OriginalSerialNumber>%s</OriginalSerialNumber>
|
|
||||||
<DeviceStatus>R</DeviceStatus>
|
|
||||||
</CheckRegistrationResponse>
|
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, CR.Version, CR.DeviceID, CR.DeviceID, timestamp, CR.SerialNo)
|
|
||||||
|
|
||||||
case "GetRegistrationInfo":
|
case "GetRegistrationInfo":
|
||||||
fmt.Println("GRI.")
|
fmt.Println("GRI.")
|
||||||
@ -86,29 +66,15 @@ func iasHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(GRI)
|
fmt.Println(GRI)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<AccountId>%s</AccountId>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<GetRegistrationInfoResponse xmlns="urn:ias.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<AccountId>%s</AccountId>
|
|
||||||
<DeviceToken>00000000</DeviceToken>
|
<DeviceToken>00000000</DeviceToken>
|
||||||
<DeviceTokenExpired>false</DeviceTokenExpired>
|
<DeviceTokenExpired>false</DeviceTokenExpired>
|
||||||
<Country>%s</Country>
|
<Country>%s</Country>
|
||||||
<ExtAccountId></ExtAccountId>
|
<ExtAccountId></ExtAccountId>
|
||||||
<DeviceCode>0000000000000000</DeviceCode>
|
<DeviceCode>0000000000000000</DeviceCode>
|
||||||
<DeviceStatus>R</DeviceStatus>
|
<DeviceStatus>R</DeviceStatus>
|
||||||
<Currency>POINTS</Currency>
|
<Currency>POINTS</Currency>`, GRI.AccountID, GRI.Country)
|
||||||
</GetRegistrationInfoResponse>
|
fmt.Fprint(w, formatSuccess("ias", action, GRI.Version, GRI.DeviceID, GRI.MessageID, custom))
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, GRI.Version, GRI.DeviceID, GRI.MessageID, timestamp, GRI.AccountID, GRI.Country)
|
|
||||||
|
|
||||||
case "Register":
|
case "Register":
|
||||||
fmt.Println("REG.")
|
fmt.Println("REG.")
|
||||||
@ -121,26 +87,12 @@ func iasHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(REG)
|
fmt.Println(REG)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
custom := fmt.Sprintf(`<AccountId>%s</AccountId>
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<RegisterResponse xmlns="urn:ias.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
<AccountId>%s</AccountId>
|
|
||||||
<DeviceToken>00000000</DeviceToken>
|
<DeviceToken>00000000</DeviceToken>
|
||||||
<Country>%s</Country>
|
<Country>%s</Country>
|
||||||
<ExtAccountId></ExtAccountId>
|
<ExtAccountId></ExtAccountId>
|
||||||
<DeviceCode>00000000</DeviceCode>
|
<DeviceCode>00000000</DeviceCode>`, REG.AccountID, REG.Country)
|
||||||
</RegisterResponse>
|
fmt.Fprint(w, formatSuccess("ias", action, REG.Version, REG.DeviceID, REG.MessageID, custom))
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, REG.Version, REG.DeviceID, REG.MessageID, timestamp, REG.AccountID, REG.Country)
|
|
||||||
|
|
||||||
case "Unregister":
|
case "Unregister":
|
||||||
fmt.Println("UNR.")
|
fmt.Println("UNR.")
|
||||||
@ -153,22 +105,10 @@ func iasHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
fmt.Println(UNR)
|
fmt.Println(UNR)
|
||||||
fmt.Println("The request is valid! Responding...")
|
fmt.Println("The request is valid! Responding...")
|
||||||
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
|
fmt.Fprint(w, formatSuccess("ias", action, UNR.Version, UNR.DeviceID, UNR.MessageID, ""))
|
||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<soapenv:Body>
|
|
||||||
<UnregisterResponse xmlns="urn:ias.wsapi.broadon.com">
|
|
||||||
<Version>%s</Version>
|
|
||||||
<DeviceId>%s</DeviceId>
|
|
||||||
<MessageId>%s</MessageId>
|
|
||||||
<TimeStamp>%s</TimeStamp>
|
|
||||||
<ErrorCode>0</ErrorCode>
|
|
||||||
<ServiceStandbyMode>false</ServiceStandbyMode>
|
|
||||||
</UnregisterResponse>
|
|
||||||
</soapenv:Body>
|
|
||||||
</soapenv:Envelope>`, UNR.Version, UNR.DeviceID, UNR.MessageID, timestamp)
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(w, "WiiSOAP can't handle this. Try again later or actually use a Wii instead of a computer.")
|
fmt.Fprint(w, "WiiSOAP can't handle this. Try again later or actually use a Wii instead of a computer.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
main.go
23
main.go
@ -29,10 +29,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Header is a generic XML header suitable for use with the output of Marshal.
|
// Header is the base format of a SOAP response with string substitutions available.
|
||||||
// This is not automatically added to any output of this package,
|
// All XML constants must be treated as temporary until a proper XPath solution is investigated.
|
||||||
// it is provided as a convenience.
|
Header = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<soapenv:Body>
|
||||||
|
<%sResponse xmlns="%s">` + "\n"
|
||||||
|
// Template describes common fields across all requests, for easy replication.
|
||||||
|
Template = ` <Version>%s</Version>
|
||||||
|
<DeviceId>%s</DeviceId>
|
||||||
|
<MessageId>%s</MessageId>
|
||||||
|
<TimeStamp>%s</TimeStamp>
|
||||||
|
<ErrorCode>%d</ErrorCode>
|
||||||
|
<ServiceStandbyMode>false</ServiceStandbyMode>` + "\n"
|
||||||
|
// Footer is the base format of a closing envelope in SOAP.
|
||||||
|
Footer = ` </%sResponse>
|
||||||
|
</soapenv:Body>
|
||||||
|
</soapenv:Envelope>`
|
||||||
)
|
)
|
||||||
|
|
||||||
// checkError makes error handling not as ugly and inefficient.
|
// checkError makes error handling not as ugly and inefficient.
|
||||||
|
49
utils.go
49
utils.go
@ -17,13 +17,19 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// namespaceForType returns the expected XML namespace format for a service.
|
||||||
func namespaceForType(service string) string {
|
func namespaceForType(service string) string {
|
||||||
return "urn:" + service + ".wsapi.broadon.com"
|
return "urn:" + service + ".wsapi.broadon.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expected contents are along the lines of "urn:ecs.wsapi.broadon.com/CheckDeviceStatus"
|
// parseAction interprets contents along the lines of "urn:ecs.wsapi.broadon.com/CheckDeviceStatus".
|
||||||
func parseAction(original string, service string) string {
|
func parseAction(original string, service string) string {
|
||||||
prefix := namespaceForType(service) + "/"
|
prefix := namespaceForType(service) + "/"
|
||||||
stripped := strings.Replace(original, prefix, "", 1)
|
stripped := strings.Replace(original, prefix, "", 1)
|
||||||
@ -35,3 +41,42 @@ func parseAction(original string, service string) string {
|
|||||||
return stripped
|
return stripped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatHeader formats a response type and the proper service.
|
||||||
|
func formatHeader(responseType string, service string) string {
|
||||||
|
return fmt.Sprintf(Header, responseType, namespaceForType(service))
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatTemplate inserts common, cross-requests values into every request.
|
||||||
|
func formatTemplate(version string, deviceId string, messageId string, errorCode int) string {
|
||||||
|
// Get a sexy new timestamp to use.
|
||||||
|
timestampNano := strconv.FormatInt(time.Now().UTC().Unix(), 10)
|
||||||
|
timestamp := timestampNano + "000"
|
||||||
|
|
||||||
|
return fmt.Sprintf(Template, version, deviceId, messageId, timestamp, errorCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatFooter formats the closing tags of any SOAP request per previous response type.
|
||||||
|
func formatFooter(responseType string) string {
|
||||||
|
return fmt.Sprintf(Footer, responseType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatForNamespace mangles together several variables throughout a SOAP request.
|
||||||
|
func formatForNamespace(service string, responseType string, version string, deviceId string, messageId string, errorCode int, extraContents string) string {
|
||||||
|
return fmt.Sprintf("%s%s%s%s",
|
||||||
|
formatHeader(responseType, service),
|
||||||
|
formatTemplate(version, deviceId, messageId, errorCode),
|
||||||
|
"\t\t"+extraContents,
|
||||||
|
formatFooter(responseType),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatSuccess returns a standard SOAP response with a positive error code, and additional contents.
|
||||||
|
func formatSuccess(service string, responseType string, version string, deviceId string, messageId string, extraContents string) string {
|
||||||
|
return formatForNamespace(service, responseType, version, deviceId, messageId, 0, extraContents)
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatError returns a standard SOAP response with an error code.
|
||||||
|
func formatError(service string, responseType string, version string, deviceId string, messageId string, errorCode int) string {
|
||||||
|
return formatForNamespace(service, responseType, version, deviceId, messageId, errorCode, "")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user