From cebd33c61a5468a736ee8013fc5f454c61f51e3d Mon Sep 17 00:00:00 2001 From: CornierKhan1 Date: Thu, 6 Sep 2018 09:57:57 +1000 Subject: [PATCH] CDS now works. --- main.go | 68 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/main.go b/main.go index edb3252..ed99a00 100644 --- a/main.go +++ b/main.go @@ -26,8 +26,6 @@ import ( "net/http" ) -// The Check struct(ure) will attempt to retrieve all the namespace data. -// Assuming that namespaces that don't exist are given a "nil", the first result that isn't a "nil" will be used as the template response. const ( // Header is a generic XML header suitable for use with the output of Marshal. // This is not automatically added to any output of this package, @@ -35,7 +33,15 @@ const ( Header = `` + "\n" ) +///////////////////// +// SOAP STRUCTURES // +///////////////////// + type CDS struct { + XMLName xml.Name `xml:"Envelope"` + Version string `xml:"Body>CheckDeviceStatus>Version"` + DeviceId string `xml:"Body>CheckDeviceStatus>DeviceId"` + MessageId string `xml:"Body>CheckDeviceStatus>MessageId"` } type NETS struct { } @@ -66,23 +72,49 @@ func handler(w http.ResponseWriter, r *http.Request) { 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.Printf("error: %v", err) - return - } - } - } - fmt.Println(body) + fmt.Println(CDS) + fmt.Println("The request is valid! Responding...") + fmt.Fprintf(w, ` + + + + + 2.0 + `+CDS.DeviceId+` + `+CDS.MessageId+` + 00000000 + 0 + false + + 2018 + POINTS + + 0 + 00000000 + 00000000 + + +`) + fmt.Println("Delivered response!") + + } 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.Printf("error: %v", err) + return + } + } + } fmt.Println("End of Request.") }