changeset 3324:96dbfcc614be

Backed out changeset bd1385c00b59
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 20 May 2019 12:10:44 +0200
parents de0d0685a17b
children 496cf0474e29
files pkg/soap/soap.go
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/soap/soap.go	Mon May 20 11:46:06 2019 +0200
+++ b/pkg/soap/soap.go	Mon May 20 12:10:44 2019 +0200
@@ -230,13 +230,6 @@
 	s.headers = append(s.headers, header)
 }
 
-func shorten(s string) string {
-	if len(s) < 40 {
-		return s
-	}
-	return fmt.Sprintf("%.40q...", s)
-}
-
 func (s *SOAPClient) Call(soapAction string, request, response interface{}) error {
 	envelope := SOAPEnvelope{}
 
@@ -302,20 +295,22 @@
 	if err != nil {
 		return err
 	}
+	if res.StatusCode < http.StatusOK || res.StatusCode > 299 {
+		return fmt.Errorf(
+			"HTTP error: %d (%s)", res.StatusCode, http.StatusText(res.StatusCode))
+	}
 	defer res.Body.Close()
 
 	rawbody, err := ioutil.ReadAll(res.Body)
 	if err != nil {
 		return err
 	}
-
-	if res.StatusCode < http.StatusOK || res.StatusCode > 299 {
-		short := shorten(string(rawbody))
-		log.Printf("error: response from SOAP service:\n%s", short)
-		return fmt.Errorf("Error requesting SOAP service: %d (%s): %s",
-			res.StatusCode, http.StatusText(res.StatusCode), short)
+	if len(rawbody) == 0 {
+		log.Println("empty response")
+		return nil
 	}
 
+	//log.Println(string(rawbody))
 	respEnvelope := new(SOAPEnvelope)
 	respEnvelope.Body = SOAPBody{Content: response}
 	err = xml.Unmarshal(rawbody, respEnvelope)
@@ -323,5 +318,10 @@
 		return err
 	}
 
-	return respEnvelope.Body.Fault
+	fault := respEnvelope.Body.Fault
+	if fault != nil {
+		return fault
+	}
+
+	return nil
 }