code: def parse_soap_enveloped_saml_thingy(text, expected_tags):
      
      envelope = defusedxml.ElementTree.fromstring(text)
  
      # Make sure it's a SOAP message
      assert envelope.tag == '{%s}Envelope' % soapenv.NAMESPACE
  
      assert len(envelope) >= 1
      body = None
      for part in envelope:
          if part.tag == '{%s}Body' % soapenv.NAMESPACE:
              assert len(part) == 1
              body = part
              break
  
      if body is None:
          return ""
  
      saml_part = body[0]
      if saml_part.tag in expected_tags:
          return ElementTree.tostring(saml_part, encoding="UTF-8")
      else:
          raise WrongMessageType("Was '%s' expected one of %s" % (saml_part.tag,
                                                                  expected_tags))
docs: Parses a SOAP enveloped SAML thing and returns the thing as
      a string.
  
      :param text: The SOAP object as XML string
      :param expected_tags: What the tag of the SAML thingy is expected to be.
      :return: SAML thingy as a string