Search in sources :

Example 36 with AS4RawResponseConsumerWriteToFile

use of com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile in project phase4 by phax.

the class MainPhase4PeppolSenderConstantReceiverSG2 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/Singapore invoice valid 1.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("0192:810418052");
        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#conformant#urn:fdc:peppol.eu:2017:poacc:billing:international:sg: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).receiverEndpointDetails(CertificateHelper.convertStringToCertficate("-----BEGIN CERTIFICATE-----\n" + "MIIF2zCCA8OgAwIBAgIQDyXLqdKdJNF+okAUGXN3izANBgkqhkiG9w0BAQsFADBr\n" + "MQswCQYDVQQGEwJCRTEZMBcGA1UEChMQT3BlblBFUFBPTCBBSVNCTDEWMBQGA1UE\n" + "CxMNRk9SIFRFU1QgT05MWTEpMCcGA1UEAxMgUEVQUE9MIEFDQ0VTUyBQT0lOVCBU\n" + "RVNUIENBIC0gRzIwHhcNMjA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QIDAQGBqZDhAxYGOTU3NjA4\n" + "MDkGCmCGSAGG+EUBEAUEKzApAgEAFiRhSFIwY0hNNkx5OXdhMmt0Y21FdWMzbHRZ\n" + "WFYwYUM1amIyMD0wDQYJKoZIhvcNAQELBQADggIBAE4naY2C13P4CYR+R3sDwBDU\n" + "JNG6TnFMojGvRXIXSdMFbUotGnED8nhA8q8fS3HIRlXDBnBODODuQBmTPj+zjR2U\n" + "6NFa+ji0mH5obimY/DhB3XeGI3wwxZEr/gi2dDjpdIRpAfwvoIo2E/JczXacNk9C\n" + "Koa5LRpSGLXAwtuPvrDkvcdGYZG5IxldnTcVpan8jU92OjEg8QNWYvtuYTygVYBU\n" + "itFt0vTNxs5+TivDFtOf+SjGmNzKtlFhb5ITM0QWARuTHmBYy5fUZfbKWvTWcOZl\n" + "ieuYT+s1o7tIkLJ62Y7/Qn3xWfVfDEBD40bYVCBQWHv8IGHQUDC/ZdMoeM1Yx3tm\n" + "POveFZodbbI8SjTrpJuGO8nZ/f6dXG4JUXOSs9lR1B17T5FnprQn+B9xiFuVU6mb\n" + "rxoXT7hlt1s+ntFXB8MecZk+a4lprjBumZRqwkQmFjMDZaATZs9hKANstda1qPrz\n" + "RxtRrgzU1dZfUkDNxfEauLug9VPl64UvNgWIhsSfLbPj+AkFn9rXXg2PmeKx7AEL\n" + "gXFSqahkh+96DcKlIc49Os2ew16iJEC+X+kMsMxjZXjkQoMxI1LF7IhGABQctof2\n" + "QsSm4/2kuGIsWKRy+kf7s7xJT7olo1hBQQzNf1J1GN4WbXVWtkxD1jyXML+HnYfh\n" + "47A9zzduKT3CycRoqxaB\n" + "-----END CERTIFICATE-----"), "https://dev.einvoicing.i-portal.biz/msh").rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).validationConfiguration(PeppolValidationSG.VID_OPENPEPPOL_BIS3_SG_UBL_INVOICE_103, 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 : 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 37 with AS4RawResponseConsumerWriteToFile

use of com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile in project phase4 by phax.

the class MainPhase4PeppolSenderStorecoveConstantReceiver 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("0106:sc998899889");
        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).receiverEndpointDetails(CertificateHelper.convertStringToCertficate("-----BEGIN CERTIFICATE-----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XjzBQuF1wdECMQAHNTrwzHziw4S/ZMf5KELc1ezYF61NAfCb8voMzFCJn4n1XK+\r\n" + "hBQpCt8=\r\n" + "-----END CERTIFICATE-----\r\n"), false ? "https://o96st7ob6h.execute-api.eu-west-1.amazonaws.com/prod/as4" : "https://accap.mypeppol.app/as4").rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).sendMessageAndCheckForReceipt();
        LOGGER.info("Peppol send result: " + eResult);
    } catch (final Exception ex) {
        LOGGER.error("Error sending Peppol message via AS4", ex);
    }
}
Also used : ESimpleUserMessageSendResult(com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult) Element(org.w3c.dom.Element) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) AS4RawResponseConsumerWriteToFile(com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile) File(java.io.File) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 38 with AS4RawResponseConsumerWriteToFile

use of com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile in project phase4 by phax.

the class MainPhase4PeppolSenderTradeshift 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("9902:DK35391282");
        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;
        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()).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)

Aggregations

IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)38 AS4RawResponseConsumerWriteToFile (com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile)38 File (java.io.File)38 ESimpleUserMessageSendResult (com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult)37 Element (org.w3c.dom.Element)37 AS4IncomingDumperFileBased (com.helger.phase4.dump.AS4IncomingDumperFileBased)33 AS4OutgoingDumperFileBased (com.helger.phase4.dump.AS4OutgoingDumperFileBased)33 SMPClientReadOnly (com.helger.smpclient.peppol.SMPClientReadOnly)30 IAS4ClientBuildMessageCallback (com.helger.phase4.client.IAS4ClientBuildMessageCallback)13 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)13 AbstractAS4Message (com.helger.phase4.messaging.domain.AbstractAS4Message)13 IValidationSourceXML (com.helger.phive.engine.source.IValidationSourceXML)4 IAS4RawResponseConsumer (com.helger.phase4.client.IAS4RawResponseConsumer)3 IAS4CryptoFactory (com.helger.phase4.crypto.IAS4CryptoFactory)3 HttpRetrySettings (com.helger.phase4.http.HttpRetrySettings)3 ESML (com.helger.peppol.sml.ESML)2 AS4CryptoFactoryInMemoryKeyStore (com.helger.phase4.crypto.AS4CryptoFactoryInMemoryKeyStore)2 AS4DumpManager (com.helger.phase4.dump.AS4DumpManager)2 MockServletContext (com.helger.servlet.mock.MockServletContext)2 WebScopeManager (com.helger.web.scope.mgr.WebScopeManager)2