mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-06 05:21:04 +02:00
More efficient, checking actually works.
This commit is contained in:
parent
5f40b35e1b
commit
b26bc86266
58
main.go
58
main.go
@ -18,6 +18,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -34,22 +35,9 @@ const (
|
|||||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Check struct {
|
type CDS struct {
|
||||||
|
}
|
||||||
// SOAP envelope doesn't matter to OSC. We'll only need the BODY.
|
type NETS struct {
|
||||||
SOAP xml.Name `xml:"SOAP-ENV:Body"`
|
|
||||||
|
|
||||||
// ECommerce Namespaces
|
|
||||||
CDS string `xml:"CheckDeviceStatus>Version"`
|
|
||||||
LET string `xml:"ListETickets>Version"`
|
|
||||||
NETS string `xml:"NotifyETicketsSynced>Version"`
|
|
||||||
PT string `xml:"PurchaseTitle>Version"`
|
|
||||||
|
|
||||||
// Identity Authentication Namespaces
|
|
||||||
CR string `ias:"CheckRegistration>Version"`
|
|
||||||
GRI string `ias:"GetRegistrationInfo>Version"`
|
|
||||||
REG string `ias:"Register>Version"`
|
|
||||||
UNR string `ias:"Unregister>Version"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -59,29 +47,41 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
ChRes := Check{
|
fmt.Println("Incoming request! (Processing...)")
|
||||||
SOAP: xml.Name{},
|
|
||||||
CDS: "",
|
|
||||||
LET: "",
|
|
||||||
NETS: "",
|
|
||||||
PT: "",
|
|
||||||
CR: "",
|
|
||||||
GRI: "",
|
|
||||||
REG: "",
|
|
||||||
UNR: "",
|
|
||||||
}
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Error reading request body",
|
http.Error(w, "Error reading request body",
|
||||||
http.StatusInternalServerError)
|
http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = xml.Unmarshal([]byte(body), &ChRes)
|
// The following block of code here is a cluster of disgust.
|
||||||
|
|
||||||
|
// CheckDeviceStatus
|
||||||
|
if bytes.Contains(body, []byte("CheckDeviceStatus")) {
|
||||||
|
fmt.Println("CDS.")
|
||||||
|
CDS := CDS{}
|
||||||
|
err = xml.Unmarshal([]byte(body), &CDS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(ChRes)
|
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||||
|
fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)")
|
||||||
|
fmt.Printf("error: %v", err)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// NotifyETicketsSynced.
|
||||||
|
if bytes.Contains(body, []byte("NotifyETicketsSynced")) {
|
||||||
|
fmt.Println("NETS")
|
||||||
|
NETS := NETS{}
|
||||||
|
err = xml.Unmarshal([]byte(body), &NETS)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||||
fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)")
|
fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)")
|
||||||
fmt.Printf("error: %v", err)
|
fmt.Printf("error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
fmt.Println(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user