SPSSODescriptor spDescriptor = (SPSSODescriptor) context.getLocalEntityRoleMetadata();
AssertionConsumerService assertionConsumer = getAssertionConsumerService(options, null, spDescriptor);
// The last parameter refers to the IdP that should receive the message. However,
// in ECP, we don't know in advance which IdP will be contacted.
AuthnRequest authRequest = getAuthnRequest(context, options, assertionConsumer, null);
context.setCommunicationProfileId(getProfileIdentifier());
context.setOutboundMessage(getEnvelope());
context.setOutboundSAMLMessage(authRequest);
SOAPHelper.addHeaderBlock(context, getPAOSRequest(assertionConsumer));
SOAPHelper.addHeaderBlock(context, getECPRequest(context, options));
sendMessage(context, spDescriptor.isAuthnRequestsSigned(), SAMLConstants.SAML2_PAOS_BINDING_URI);
HTTPOutTransport outTransport = (HTTPOutTransport) context.getOutboundMessageTransport();
outTransport.setHeader("Content-Type", "application/vnd.paos+xml");
SAMLMessageStorage messageStorage = context.getMessageStorage();
if (messageStorage != null) {
messageStorage.storeMessage(authRequest.getID(), authRequest);
}
}