# HG changeset patch # User Sascha L. Teichmann # Date 1558347044 -7200 # Node ID 96dbfcc614beee7bf6ccb5abdcfef2560b47e450 # Parent de0d0685a17bafae8cde925ed410eadef9908463 Backed out changeset bd1385c00b59 diff -r de0d0685a17b -r 96dbfcc614be pkg/soap/soap.go --- 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 }