Search in sources :

Example 1 with Phase4OutgoingAttachment

use of com.helger.phase4.attachment.Phase4OutgoingAttachment in project phase4 by phax.

the class AbstractAS4UserMessageBuilderMIMEPayload method mainSendMessage.

@Override
protected final void mainSendMessage() throws Phase4Exception {
    // Temporary file manager
    try (final AS4ResourceHelper aResHelper = new AS4ResourceHelper()) {
        // Start building AS4 User Message
        final AS4ClientUserMessage aUserMsg = new AS4ClientUserMessage(aResHelper);
        applyToUserMessage(aUserMsg);
        // No payload - only one attachment
        aUserMsg.setPayload(null);
        // Add main attachment
        aUserMsg.addAttachment(WSS4JAttachment.createOutgoingFileAttachment(m_aPayload, aResHelper));
        // Add other attachments
        for (final Phase4OutgoingAttachment aAttachment : m_aAttachments) aUserMsg.addAttachment(WSS4JAttachment.createOutgoingFileAttachment(aAttachment, aResHelper));
        // Main sending
        AS4BidirectionalClientHelper.sendAS4UserMessageAndReceiveAS4SignalMessage(m_aCryptoFactory, pmodeResolver(), incomingAttachmentFactory(), incomingProfileSelector(), aUserMsg, m_aLocale, m_sEndpointURL, m_aBuildMessageCallback, m_aOutgoingDumper, m_aIncomingDumper, m_aRetryCallback, m_aResponseConsumer, m_aSignalMsgConsumer);
    } catch (final Phase4Exception ex) {
        // Re-throw
        throw ex;
    } catch (final Exception ex) {
        // wrap
        throw new Phase4Exception("Wrapped Phase4Exception", ex);
    }
}
Also used : Phase4Exception(com.helger.phase4.util.Phase4Exception) Phase4OutgoingAttachment(com.helger.phase4.attachment.Phase4OutgoingAttachment) AS4ClientUserMessage(com.helger.phase4.client.AS4ClientUserMessage) AS4ResourceHelper(com.helger.phase4.util.AS4ResourceHelper) Phase4Exception(com.helger.phase4.util.Phase4Exception)

Aggregations

Phase4OutgoingAttachment (com.helger.phase4.attachment.Phase4OutgoingAttachment)1 AS4ClientUserMessage (com.helger.phase4.client.AS4ClientUserMessage)1 AS4ResourceHelper (com.helger.phase4.util.AS4ResourceHelper)1 Phase4Exception (com.helger.phase4.util.Phase4Exception)1