@Override
    public Envelope build(final SamlProfileBuilderContext context) throws Exception {

        context.getHttpResponse().setContentType(MediaType.APPLICATION_XML_VALUE);
        val header = SamlUtils.newSoapObject(Header.class);
        val body = SamlUtils.newSoapObject(Body.class);
        val query = (AttributeQuery) context.getSamlRequest();

        val scratch = context.getMessageContext().ensureSubcontext(ScratchContext.class);
        val map = (Map) Objects.requireNonNull(scratch).getMap();
        map.put(SamlProtocolConstants.PARAMETER_ENCODE_RESPONSE, Boolean.FALSE);

        val buildContext = context.transferTo(query, SAMLConstants.SAML2_POST_BINDING_URI);
        val saml2Response = buildSaml2Response(buildContext);
        body.getUnknownXMLObjects().add(saml2Response);

        val envelope = SamlUtils.newSoapObject(Envelope.class);
        envelope.setHeader(header);
        envelope.setBody(body);
        openSamlConfigBean.logObject(envelope);

        map.remove(SamlProtocolConstants.PARAMETER_ENCODE_RESPONSE);
        return encodeFinalResponse(context, envelope);
    }
This is {@link SamlProfileAttributeQueryResponseBuilder}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/builders/response/query/SamlProfileAttributeQueryResponseBuilder.java