get error message from soap message

This commit is contained in:
w1ndyb0y
2020-09-16 22:53:57 +08:00
parent 4dcc256c28
commit 49d4b0c32a
3 changed files with 22 additions and 1 deletions
+12
View File
@@ -84,6 +84,7 @@ const (
`
msgExp = `<ns1:string>.*<\/ns1:string>`
errExp = `<errorMessage .*<\/errorMessage>`
)
// CreateSend xml string for sending
@@ -122,6 +123,17 @@ func GetMsgs(soap string) []string {
return Map(msgs, split)
}
//GetErrMsg get error message
func GetErrMsg(soap string) string {
r, _ := regexp.Compile(errExp)
msg := r.FindAllString(soap, -1)
if len(msg) > 0 && len(msg[0]) > 40 {
size := len(msg[0])
return msg[0][54 : size-15]
}
return msg[0]
}
func split(msg string) string {
if len(msg) > 12 {
return msg[12 : len(msg)-13]