mirror of
https://github.com/kerberos-io/onvif.git
synced 2025-10-06 16:27:05 +08:00
29 lines
677 B
Go
29 lines
677 B
Go
package networking
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// SendSoap send soap message
|
|
func SendSoap(endpoint, message string) (*http.Response, error) {
|
|
httpClient := new(http.Client)
|
|
|
|
resp, err := httpClient.Post(endpoint, "application/soap+xml; charset=utf-8", bytes.NewBufferString(message))
|
|
if err != nil {
|
|
return resp, err
|
|
}
|
|
|
|
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))
|
|
}
|