deserialize XML message strings into SOAP envelope objects
(data, ipAddr)
| 27 | |
| 28 | |
| 29 | def parseSOAPMessage(data, ipAddr): |
| 30 | "deserialize XML message strings into SOAP envelope objects" |
| 31 | try: |
| 32 | dom = minidom.parseString(data) |
| 33 | except Exception as ex: |
| 34 | logger.debug('Failed to parse message from %s\n%s: %s', ipAddr, data, ex) |
| 35 | return None |
| 36 | |
| 37 | if dom.getElementsByTagNameNS(NS_SOAPENV, "Fault"): |
| 38 | logger.debug('Fault received from %s: %s', ipAddr, data) |
| 39 | return None |
| 40 | |
| 41 | actions = dom.getElementsByTagNameNS(NS_ADDRESSING, "Action") |
| 42 | if len(actions) == 0: |
| 43 | logger.warning('No action received from %s: %s', ipAddr, data) |
| 44 | return None |
| 45 | |
| 46 | soapAction = actions[0].firstChild.data.strip() |
| 47 | if soapAction == NS_ACTION_PROBE: |
| 48 | return parseProbeMessage(dom) |
| 49 | elif soapAction == NS_ACTION_PROBE_MATCH: |
| 50 | return parseProbeMatchMessage(dom) |
| 51 | elif soapAction == NS_ACTION_RESOLVE: |
| 52 | return parseResolveMessage(dom) |
| 53 | elif soapAction == NS_ACTION_RESOLVE_MATCH: |
| 54 | return parseResolveMatchMessage(dom) |
| 55 | elif soapAction == NS_ACTION_BYE: |
| 56 | return parseByeMessage(dom) |
| 57 | elif soapAction == NS_ACTION_HELLO: |
| 58 | return parseHelloMessage(dom) |
no test coverage detected