import (
"encoding/xml"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func SoapServer() {
DEBUG("SAOP:"+ip+soap_port)
s := NewSOAPServer(ip+soap_port)
log.Fatal(s.ListenAndServe())
}
func NewSOAPMux() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/", soapHandler)
return mux
}
func NewSOAPServer(addr string) *http.Server {
mux := NewSOAPMux()
server := &http.Server{
Handler: mux,
Addr: addr,
}
return server
}
func soapHandler(w http.ResponseWriter, r *http.Request) {
rawBody, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
v := SConfig{}
err = xml.Unmarshal(rawBody, &v)
if err != nil {
fmt.Printf("error: %v", err)
return
}
fmt.Println(v)
}
网友评论