From be84cab1fe34f278c0659203f20f82b1ba11bc2b Mon Sep 17 00:00:00 2001 From: Edward Date: Fri, 1 May 2020 22:58:33 +0800 Subject: [PATCH] add SendSoapWithTimeout --- networking/networking.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/networking/networking.go b/networking/networking.go index d36d907..f4047ca 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -1,10 +1,12 @@ package networking import ( - "net/http" "bytes" + "net/http" + "time" ) +// SendSoap send soap message func SendSoap(endpoint, message string) (*http.Response, error) { httpClient := new(http.Client) @@ -13,5 +15,14 @@ func SendSoap(endpoint, message string) (*http.Response, error) { return resp, err } - return resp,nil -} \ No newline at end of file + return resp, nil +} + +// SendSoapWithTimeout send soap message with timeOut +func SendSoapWithTimeout(endpoint string, message []byte, timeout time.Duration) (*http.Response, error) { + httpClient := &http.Client{ + Timeout: timeout, + } + + return httpClient.Post(endpoint, "application/soap+xml; charset=utf-8", bytes.NewReader(message)) +}