 create_metadata = (issuer, assert_endpoint, signing_certificate, encryption_certificate) ->
   xmlbuilder.create
     'md:EntityDescriptor':
-      '@xmlns:md': 'urn:oasis:names:tc:SAML:2.0:metadata'
-      '@xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#'
+      '@xmlns:md': xmlns.md
+      '@xmlns:ds': xmlns.ds
       '@entityID': issuer
       'md:SPSSODescriptor': [
           '@protocolSupportEnumeration': 'urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol',

          setImmediate cb_wf, null, raw
        (response_buffer, cb_wf) ->
          saml_response = (new xmldom.DOMParser()).parseFromString(response_buffer.toString())
          async.lift(parse_response_header) saml_response, cb_wf
        (response_header, cb_wf) =>
          response = { response_header }
          cb_wf new Error("SAML Response was not success!") unless check_status_success(saml_response)
          switch
            when saml_response.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:protocol', 'Response').length is 1
              response.type = 'authn_response'
              parse_authn_response saml_response, @private_key, identity_provider.certificate, cb_wf
            when saml_response.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:protocol', 'LogoutResponse').length is 1
              response.type = 'logout_response'
              setImmediate cb_wf, null, {}
        (result, cb_wf) ->

# appear to be valid.
parse_response_header = (dom) ->
  for response_type in ['Response', 'LogoutResponse']
    response = dom.getElementsByTagNameNS(xmlns.samlp, response_type)
    break if response.length > 0
  throw new Error("Expected 1 Response; found #{response.length}") unless response.length is 1

