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)

}

 

posted @ 2022-07-29 08:53  酷酷的城池  阅读(619)  评论(0编辑  收藏  举报