Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (23 sloc) 470 Bytes
package gosoap
import (
"encoding/xml"
"fmt"
)
// Soap Response
type Response struct {
Body []byte
Header []byte
Payload []byte
}
// Unmarshal get the body and unmarshal into the interface
func (r *Response) Unmarshal(v interface{}) error {
if len(r.Body) == 0 {
return fmt.Errorf("Body is empty")
}
var f Fault
xml.Unmarshal(r.Body, &f)
if f.Code != "" {
return fmt.Errorf("[%s]: %s", f.Code, f.Description)
}
return xml.Unmarshal(r.Body, v)
}
You can’t perform that action at this time.