Search in sources :

Example 31 with ESimpleUserMessageSendResult

use of com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult in project phase4 by phax.

the class MainPhase4PeppolSenderGenerix method main.

public static void main(final String[] args) {
    WebScopeManager.onGlobalBegin(MockServletContext.create());
    // Dump (for debugging purpose only)
    AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased());
    AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased());
    try {
        final Element aPayloadElement = DOMReader.readXMLDOM(new File("src/test/resources/examples/base-example.xml")).getDocumentElement();
        if (aPayloadElement == null)
            throw new IllegalStateException("Failed to read XML file to be send");
        // Start configuring here
        final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:generixtest");
        final ESimpleUserMessageSendResult eResult;
        eResult = Phase4PeppolSender.builder().documentTypeID(Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1")).processID(Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0")).senderParticipantID(Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:phase4-test-sender")).receiverParticipantID(aReceiverID).senderPartyID("POP000306").payload(aPayloadElement).smpClient(new SMPClientReadOnly(Phase4PeppolSender.URL_PROVIDER, aReceiverID, ESML.DIGIT_TEST)).rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).validationConfiguration(PeppolValidation3_13_0.VID_OPENPEPPOL_INVOICE_V3, new Phase4PeppolValidatonResultHandler()).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    } finally {
        WebScopeManager.onGlobalEnd();
    }
}
Also used : SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) Element(org.w3c.dom.Element) AS4IncomingDumperFileBased(com.helger.phase4.dump.AS4IncomingDumperFileBased) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) AS4OutgoingDumperFileBased(com.helger.phase4.dump.AS4OutgoingDumperFileBased) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 32 with ESimpleUserMessageSendResult

use of com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult in project phase4 by phax.

the class MainPhase4PeppolSenderGovernikus method main.

public static void main(final String[] args) {
    WebScopeManager.onGlobalBegin(MockServletContext.create());
    // Dump (for debugging purpose only)
    AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased());
    AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased());
    try {
        final Element aPayloadElement = DOMReader.readXMLDOM(new File("src/test/resources/examples/base-example.xml")).getDocumentElement();
        if (aPayloadElement == null)
            throw new IllegalStateException("Failed to read XML file to be send");
        // Start configuring here
        // Alternative one: 0204:gov06test-85
        final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:peppol-test-governikus-01");
        final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback() {

            public void onAS4Message(final AbstractAS4Message<?> aMsg) {
                final AS4UserMessage aUserMsg = (AS4UserMessage) aMsg;
                LOGGER.info("Sending out AS4 message with message ID '" + aUserMsg.getEbms3UserMessage().getMessageInfo().getMessageId() + "'");
                LOGGER.info("Sending out AS4 message with conversation ID '" + aUserMsg.getEbms3UserMessage().getCollaborationInfo().getConversationId() + "'");
            }
        };
        final ESimpleUserMessageSendResult eResult = Phase4PeppolSender.builder().documentTypeID(Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme(true ? "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1" : "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0::2.1")).processID(Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0")).senderParticipantID(Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:phase4-test-sender")).receiverParticipantID(aReceiverID).senderPartyID("POP000306").payload(aPayloadElement).smpClient(new SMPClientReadOnly(Phase4PeppolSender.URL_PROVIDER, aReceiverID, ESML.DIGIT_TEST)).rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).buildMessageCallback(aBuildMessageCallback).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    } finally {
        WebScopeManager.onGlobalEnd();
    }
}
Also used : IAS4ClientBuildMessageCallback(com.helger.phase4.client.IAS4ClientBuildMessageCallback) SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) Element(org.w3c.dom.Element) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) AbstractAS4Message(com.helger.phase4.messaging.domain.AbstractAS4Message) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) AS4IncomingDumperFileBased(com.helger.phase4.dump.AS4IncomingDumperFileBased) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) AS4OutgoingDumperFileBased(com.helger.phase4.dump.AS4OutgoingDumperFileBased) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 33 with ESimpleUserMessageSendResult

use of com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult in project phase4 by phax.

the class MainPhase4PeppolSenderHelger method send.

public static void send() {
    try {
        final Element aPayloadElement = DOMReader.readXMLDOM(new File("src/test/resources/examples/base-example.xml")).getDocumentElement();
        if (aPayloadElement == null)
            throw new IllegalStateException("Failed to read XML file to be send");
        // Start configuring here
        final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:helger");
        final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback() {

            public void onAS4Message(final AbstractAS4Message<?> aMsg) {
                final AS4UserMessage aUserMsg = (AS4UserMessage) aMsg;
                LOGGER.info("Sending out AS4 message with message ID '" + aUserMsg.getEbms3UserMessage().getMessageInfo().getMessageId() + "'");
                LOGGER.info("Sending out AS4 message with conversation ID '" + aUserMsg.getEbms3UserMessage().getCollaborationInfo().getConversationId() + "'");
            }
        };
        final IAS4RawResponseConsumer aRRC = new AS4RawResponseConsumerWriteToFile().setHandleStatusLine(true).setHandleHttpHeaders(true).and(x -> {
            LOGGER.info("Response status line: " + x.getResponseStatusLine());
            LOGGER.info("Response headers:");
            x.getResponseHeaders().forEachSingleHeader((k, v) -> LOGGER.info("  " + k + "=" + v), false);
        });
        final ESimpleUserMessageSendResult eResult;
        eResult = Phase4PeppolSender.builder().documentTypeID(Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1")).processID(Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0")).senderParticipantID(Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:phase4-test-sender")).receiverParticipantID(aReceiverID).senderPartyID("POP000306").payload(aPayloadElement).smpClient(new SMPClientReadOnly(Phase4PeppolSender.URL_PROVIDER, aReceiverID, ESML.DIGIT_TEST)).sbdDocumentConsumer(x -> {
            if (false)
                LOGGER.info(SBDHWriter.standardBusinessDocument().setFormattedOutput(true).getAsString(x));
        }).validationConfiguration(PeppolValidation3_13_0.VID_OPENPEPPOL_INVOICE_V3, new Phase4PeppolValidatonResultHandler()).buildMessageCallback(aBuildMessageCallback).rawResponseConsumer(aRRC).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    }
}
Also used : AS4IncomingDumperFileBased(com.helger.phase4.dump.AS4IncomingDumperFileBased) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) Logger(org.slf4j.Logger) SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) IAS4RawResponseConsumer(com.helger.phase4.client.IAS4RawResponseConsumer) AS4OutgoingDumperFileBased(com.helger.phase4.dump.AS4OutgoingDumperFileBased) LoggerFactory(org.slf4j.LoggerFactory) File(java.io.File) AS4DumpManager(com.helger.phase4.dump.AS4DumpManager) PeppolValidation3_13_0(com.helger.phive.peppol.PeppolValidation3_13_0) IAS4ClientBuildMessageCallback(com.helger.phase4.client.IAS4ClientBuildMessageCallback) DOMReader(com.helger.xml.serialize.read.DOMReader) Element(org.w3c.dom.Element) MockServletContext(com.helger.servlet.mock.MockServletContext) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) AbstractAS4Message(com.helger.phase4.messaging.domain.AbstractAS4Message) WebScopeManager(com.helger.web.scope.mgr.WebScopeManager) SBDHWriter(com.helger.sbdh.builder.SBDHWriter) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ESML(com.helger.peppol.sml.ESML) IAS4ClientBuildMessageCallback(com.helger.phase4.client.IAS4ClientBuildMessageCallback) SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) Element(org.w3c.dom.Element) IAS4RawResponseConsumer(com.helger.phase4.client.IAS4RawResponseConsumer) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) AbstractAS4Message(com.helger.phase4.messaging.domain.AbstractAS4Message) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 34 with ESimpleUserMessageSendResult

use of com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult in project phase4 by phax.

the class MainPhase4PeppolSenderHelgerLargeFile method send.

public static void send() {
    try {
        final Element aPayloadElement = DOMReader.readXMLDOM(new File("src/test/resources/examples/large-files/base-example-large-10m.xml")).getDocumentElement();
        if (aPayloadElement == null)
            throw new IllegalStateException("Failed to read XML file to be send");
        final boolean bNoValidate = false;
        // Start configuring here
        final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:helger");
        final IAS4RawResponseConsumer aRRC = new AS4RawResponseConsumerWriteToFile().setHandleStatusLine(true).setHandleHttpHeaders(true);
        final ESimpleUserMessageSendResult eResult;
        eResult = Phase4PeppolSender.builder().documentTypeID(Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1")).processID(Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0")).senderParticipantID(Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:phase4-test-sender")).receiverParticipantID(aReceiverID).senderPartyID("POP000306").payload(aPayloadElement).compressPayload(false).smpClient(new SMPClientReadOnly(Phase4PeppolSender.URL_PROVIDER, aReceiverID, ESML.DIGIT_TEST)).validationConfiguration(bNoValidate ? null : PeppolValidation3_13_0.VID_OPENPEPPOL_INVOICE_V3, bNoValidate ? null : new Phase4PeppolValidatonResultHandler()).rawResponseConsumer(aRRC).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    }
}
Also used : SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) Element(org.w3c.dom.Element) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) IAS4RawResponseConsumer(com.helger.phase4.client.IAS4RawResponseConsumer) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 35 with ESimpleUserMessageSendResult

use of com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult in project phase4 by phax.

the class MainPhase4PeppolSenderHelgerXRechnung12CII method send.

@SuppressWarnings("deprecation")
public static void send() {
    try {
        final Element aPayloadElement = DOMReader.readXMLDOM(new File("src/test/resources/examples/xrechnung-1.2-cii-example1.xml")).getDocumentElement();
        if (aPayloadElement == null)
            throw new IllegalStateException("Failed to read XML file to be send");
        // Start configuring here
        final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:helger");
        final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback() {

            public void onAS4Message(final AbstractAS4Message<?> aMsg) {
                final AS4UserMessage aUserMsg = (AS4UserMessage) aMsg;
                LOGGER.info("Sending out AS4 message with message ID '" + aUserMsg.getEbms3UserMessage().getMessageInfo().getMessageId() + "'");
                LOGGER.info("Sending out AS4 message with conversation ID '" + aUserMsg.getEbms3UserMessage().getCollaborationInfo().getConversationId() + "'");
            }
        };
        final Wrapper<Ebms3SignalMessage> aSignalMsgWrapper = new Wrapper<>();
        final IAS4RawResponseConsumer aRRC = new AS4RawResponseConsumerWriteToFile().setHandleStatusLine(true).setHandleHttpHeaders(true);
        // Add XRechnung rulesets
        final IValidationExecutorSetRegistry<IValidationSourceXML> aVESRegistry = Phase4PeppolValidation.createDefaultRegistry();
        EN16931Validation.initEN16931(aVESRegistry);
        XRechnungValidation.initXRechnung(aVESRegistry);
        final ESimpleUserMessageSendResult eResult;
        eResult = Phase4PeppolSender.builder().documentTypeID(Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme("urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100::CrossIndustryInvoice##urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2::D16B")).processID(Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0")).senderParticipantID(Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:phase4-test-sender")).receiverParticipantID(aReceiverID).senderPartyID("POP000306").payload(aPayloadElement).smpClient(new SMPClientReadOnly(Phase4PeppolSender.URL_PROVIDER, aReceiverID, ESML.DIGIT_TEST)).validationRegistry(aVESRegistry).validationConfiguration(XRechnungValidation.VID_XRECHNUNG_CII_122, new Phase4PeppolValidatonResultHandler()).buildMessageCallback(aBuildMessageCallback).rawResponseConsumer(aRRC).signalMsgConsumer(aSignalMsgWrapper::set).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    }
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) IAS4ClientBuildMessageCallback(com.helger.phase4.client.IAS4ClientBuildMessageCallback) Wrapper(com.helger.commons.wrapper.Wrapper) SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) Element(org.w3c.dom.Element) IValidationSourceXML(com.helger.phive.engine.source.IValidationSourceXML) IAS4RawResponseConsumer(com.helger.phase4.client.IAS4RawResponseConsumer) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) AbstractAS4Message(com.helger.phase4.messaging.domain.AbstractAS4Message) ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Aggregations

ESimpleUserMessageSendResult (com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult)44 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)43 File (java.io.File)43 Element (org.w3c.dom.Element)41 AS4RawResponseConsumerWriteToFile (com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile)37 AS4IncomingDumperFileBased (com.helger.phase4.dump.AS4IncomingDumperFileBased)36 AS4OutgoingDumperFileBased (com.helger.phase4.dump.AS4OutgoingDumperFileBased)36 SMPClientReadOnly (com.helger.smpclient.peppol.SMPClientReadOnly)35 IAS4ClientBuildMessageCallback (com.helger.phase4.client.IAS4ClientBuildMessageCallback)16 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)16 AbstractAS4Message (com.helger.phase4.messaging.domain.AbstractAS4Message)16 IAS4CryptoFactory (com.helger.phase4.crypto.IAS4CryptoFactory)6 HttpRetrySettings (com.helger.phase4.http.HttpRetrySettings)6 IValidationSourceXML (com.helger.phive.engine.source.IValidationSourceXML)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Wrapper (com.helger.commons.wrapper.Wrapper)3 ESML (com.helger.peppol.sml.ESML)3 IAS4RawResponseConsumer (com.helger.phase4.client.IAS4RawResponseConsumer)3 AS4CryptoFactoryInMemoryKeyStore (com.helger.phase4.crypto.AS4CryptoFactoryInMemoryKeyStore)3