Bugs fixed

This commit is contained in:
yakovlevdmv
2018-04-07 22:16:11 +03:00
parent 33464e6c7a
commit 42e62d7f52
5 changed files with 44 additions and 28 deletions

View File

@@ -3,27 +3,26 @@ package networking
import (
"net/http"
"bytes"
"io/ioutil"
"strconv"
"errors"
)
func SendSoap(endpoint, message string) (string, error) {
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 "", err
}
if resp.StatusCode != http.StatusOK {
return "", errors.New("error: got HTTP response status " + strconv.Itoa(resp.StatusCode))
}
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
return resp, err
}
/*if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusBadRequest {
return "", errors.New("error: got HTTP response status " + strconv.Itoa(resp.StatusCode))
}*/
//b, err := ioutil.ReadAll(resp.Body)
//if err != nil {
// return resp, err
//}
//fmt.Println(endpoint)
//fmt.Println(string(b))
//log.Println(resp.StatusCode)
return string(b),nil
return resp,nil
}