Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.03 KB

README.md

File metadata and controls

26 lines (21 loc) · 1.03 KB

soaptrip Build Status Coverage Status GoDoc

soaptrip is an HTTP Transport wrapper for parsing SOAP Faults

Usage

// create a client
c := &http.Client{Transport: soaptrip.DefaultSoapTrip}

// make a call that can respond with a SOAP Fault
resp, err := c.Post("http://localhost/soap/login", "text/xml", soapEnvelopeReader)
if err != nil {
	log.Println(err.Error()) // Post http://localhost/soap/login: FaultCode: 'faultcode' FaultString: 'fault string'

	// resp will always == nil if err != nil, however, you can retrieve the original resp
	urlError := err.(*url.Error)
	switch urlError.Err.(type) {
	case *soaptrip.SoapFault:
		resp = urlError.Err.Response
	default:
		// this is not a soap fault error
	}
}