@Override
    protected Envelope encode(final SamlProfileBuilderContext context,
                              final Envelope envelope,
                              final String relayState) throws Exception {
        val ctx = context.getMessageContext().ensureSubcontext(SOAP11Context.class);
        Objects.requireNonNull(ctx).setEnvelope(envelope);
        val encoder = new HTTPSOAP11Encoder();
        encoder.setHttpServletResponseSupplier(context::getHttpResponse);
        encoder.setMessageContext(context.getMessageContext());
        encoder.initialize();
        encoder.encode();
        return envelope;
    }
Build saml2 response.

@param context the context
@return the org . opensaml . saml . saml 2 . core . response
@throws Exception the exception
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/builders/response/soap/SamlProfileSamlSoap11ResponseBuilder.java