golang gosoap
作者:互联网
package main import ( "encoding/xml" "fmt" "log" "net/http" "time" "github.com/tiaguinho/gosoap" ) type GetIPLocationResponse struct { XMLName xml.Name `xml:"checkEnterInfoResponse"` Out string `xml:"out"` } var ( r GetIPLocationResponse ) func main() { httpClient := &http.Client{ Timeout: 1500 * time.Millisecond, } soap, err := gosoap.SoapClient("http://10.251.112.92/edpgf_tradingPlatform/servicesx/EnterCheckService?wsdl", httpClient) if err != nil { log.Fatalf("SoapClient error: %s", err) } // Use gosoap.ArrayParams to support fixed position params params := gosoap.Params{ "key": "11111111111111111111111111111111111111111111111111111111111111", "json": "8.8.8.8", } res, err := soap.Call("checkEnterInfo", params) if err != nil { log.Fatalf("Call error: %s", err) } res.Unmarshal(&r) fmt.Println(r.Out) }
标签:xml,http,log,err,gosoap,golang,params 来源: https://www.cnblogs.com/chengfengchi/p/16531023.html