code: def class_instances_from_soap_enveloped_saml_thingies(text, modules):
      
      try:
          envelope = defusedxml.ElementTree.fromstring(text)
      except Exception as exc:
          raise XmlParseError("%s" % exc)
  
      assert envelope.tag == '{%s}Envelope' % soapenv.NAMESPACE
      assert len(envelope) >= 1
      env = {"header": [], "body": None}
  
      for part in envelope:
          if part.tag == '{%s}Body' % soapenv.NAMESPACE:
              assert len(part) == 1
              env["body"] = instanciate_class(part[0], modules)
          elif part.tag == "{%s}Header" % soapenv.NAMESPACE:
              for item in part:
                  env["header"].append(instanciate_class(item, modules))
  
      return env
docs: Parses a SOAP enveloped header and body SAML thing and returns the
      thing as a dictionary class instance.
  
      :param text: The SOAP object as XML
      :param modules: modules representing xsd schemas
      :return: The body and headers as class instances