use of com.helger.phase4.dump.AS4IncomingDumperFileBased in project phase4 by phax.
the class MainPhase4PeppolSenderCisboxXRechnung 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/xrechnung-2.0.0-ubl-inv.xml")).getDocumentElement();
if (aPayloadElement == null)
throw new IllegalStateException("Failed to read XML file to be send");
// Add XRechnung rulesets
final IValidationExecutorSetRegistry<IValidationSourceXML> aVESRegistry = Phase4PeppolValidation.createDefaultRegistry();
EN16931Validation.initEN16931(aVESRegistry);
XRechnungValidation.initXRechnung(aVESRegistry);
// Start configuring here
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme("9915:cisbox1");
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: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()).validationRegistry(aVESRegistry).validationConfiguration(XRechnungValidation.VID_XRECHNUNG_UBL_INVOICE_200, 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();
}
}
use of com.helger.phase4.dump.AS4IncomingDumperFileBased in project phase4 by phax.
the class MainPhase4PeppolSenderComarch 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("0088:7350060300002");
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();
}
}
use of com.helger.phase4.dump.AS4IncomingDumperFileBased 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" + "RVNUIENBIC0gRzIwHhcNMjAwMjE3MDAwMDAwWhcNMjIwMjA2MjM1OTU5WjBoMRIw\n" + "EAYDVQQDDAlQU0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FIwY0hNNkx5OXdhMmt0Y21FdWMzbHRZ\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();
}
}
use of com.helger.phase4.dump.AS4IncomingDumperFileBased in project phase4 by phax.
the class MainCEFeInvoicingConnectivityTest 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 WebScoped w = new WebScoped()) {
// Read a UBL Invoice
final byte[] aPayloadBytes = SimpleFileIO.getAllFileBytes(new File("src/test/resources/examples/base-example.xml"));
if (aPayloadBytes == null)
throw new IllegalStateException();
final IAS4ClientBuildMessageCallback x1 = 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() + "'");
}
public void onSoapDocument(@Nonnull final Document aDoc) {
if (false)
LOGGER.info("SOAP Document:\n" + XMLWriter.getNodeAsString(aDoc, new XMLWriterSettings().setIndent(EXMLSerializeIndent.INDENT_AND_ALIGN)));
}
};
// TODO The message ID to use in the UI
final String sAS4MessageID = "36999089-662a-441f-95fd-470bec2b538e-100@phase4";
final ESimpleUserMessageSendResult eRes = Phase4CEFSender.builder().cryptoFactory(CF).httpRetrySettings(new HttpRetrySettings().setMaxRetries(0)).action("TC1Leg1").service("tc1", "bdx:noprocess").senderParticipantID(new SimpleParticipantIdentifier("connectivity-partid-qns", YOUR_ID)).receiverParticipantID(new SimpleParticipantIdentifier("connectivity-partid-qns", "domibus-gitb")).fromPartyIDType("urn:oasis:names:tc:ebcore:partyid-type:unregistered").fromPartyID(YOUR_ID).fromRole(CAS4.DEFAULT_INITIATOR_URL).toPartyIDType("urn:oasis:names:tc:ebcore:partyid-type:unregistered").toPartyID("domibus-gitb").toRole(CAS4.DEFAULT_RESPONDER_URL).messageID(sAS4MessageID).payload(Phase4OutgoingAttachment.builder().data(aPayloadBytes).filename("businessContentPayload").compressionGZIP().mimeType(CMimeType.TEXT_XML).contentID("message").build()).buildMessageCallback(x1).endpointDetailProvider(new AS4EndpointDetailProviderConstant(CertificateHelper.convertStringToCertficateOrNull("-----BEGIN CERTIFICATE-----\r\n" + "MIIDOzCCAiOgAwIBAgIJAKbwaKpEwNTKMA0GCSqGSIb3DQEBCwUAMDQxDTALBgNV\r\n" + "BAoMBEdJVEIxDTALBgNVBAsMBEdJVEIxFDASBgNVBAMMC2dpdGItZW5naW5lMB4X\r\n" + "DTE0MTIyNDEzMjIzNFoXDTI0MTIyMTEzMjIzNFowNDENMAsGA1UECgwER0lUQjEN\r\n" + "MAsGA1UECwwER0lUQjEUMBIGA1UEAwwLZ2l0Yi1lbmdpbmUwggEiMA0GCSqGSIb3\r\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQCpNuRRMhpd2SvNKsZe/WTxm4zuX2Zc5by3zGcm\r\n" + "uzwePdMCnCXk2FAUH67qS9r5VBa4USfiB7l1piyLrNwYWGRDo5OeWIz6Q821/1v7\r\n" + "UHq7FfB0LFPcJ+mOwrDqS+VL0MjcSW4pocJHrpFwObWHTY/R4WmW2xwGOKVh0OUL\r\n" + "UhqQsHDnDhCzFaEWhS8n1lUw3GRipwKLyYvXK8XgLceEmh+j0+cdmIj4a1L4oza/\r\n" + "UgBnCqSob+vowgClyZnGVihE9K8eLLwCSLlIiD+bXWf0VJPLXBNLdNIkRRC0QO0j\r\n" + "T9TuE5TF3SknkA5D0NFp023Alz7jieI0D6JE78QyNQN6y6QRAgMBAAGjUDBOMB0G\r\n" + "A1UdDgQWBBQpAkry20hAcvlw+4poxQC8TI+EgTAfBgNVHSMEGDAWgBQpAkry20hA\r\n" + "cvlw+4poxQC8TI+EgTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBS\r\n" + "dfmT3E9uvhiEgVefdwXkkxqlXLQQxfjaqVRVzPTHLqdVs/nBK+iQNhqg+6eLcaGQ\r\n" + "yyDy88vwQ85rqwOFbZd05esIFXYl0pgl1pVsb7HmMNmKT3UPay3HDlHX45ZoexDU\r\n" + "pza4OcrauEM8Yg/5i9dCIPC1GiHebJpYusMVfP78b+5DAyARrHtcb0EJ8rOLxHh6\r\n" + "K2S4EHI6sqQkGHEt1z4m66LyK+vnkLGaq3y6MWEufh78eICDyyVz0DhdIhr18ZHX\r\n" + "dpcsH2VOkE36KnWSo0spEXa6ZtP8MqQ60kJgBt4XcuArKfjIGC6vB6dE0NzXngBD\r\n" + "PHgMfmHJW018/6eN/f0q\r\n" + "-----END CERTIFICATE-----"), "https://www.itb.ec.europa.eu/cef/domibus/services/msh")).sendMessageAndCheckForReceipt();
LOGGER.info("Sending AS4 message to CEF with result " + eRes);
} finally {
WebScopeManager.onGlobalEnd();
}
}
use of com.helger.phase4.dump.AS4IncomingDumperFileBased in project phase4 by phax.
the class AS4WebAppListener method _initAS4.
private static void _initAS4() {
AS4ServerInitializer.initAS4Server();
// Store the incoming file as is
AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased((aMessageMetadata, aHttpHeaderMap) -> StorageHelper.getStorageFile(aMessageMetadata, ".as4in")) {
@Override
public void onEndRequest(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata) {
// Save the metadata also to a file
final File aFile = StorageHelper.getStorageFile(aMessageMetadata, ".metadata");
if (SimpleFileIO.writeFile(aFile, AS4MessagingHelper.getIncomingMetadataAsJson(aMessageMetadata).getAsJsonString(JsonWriterSettings.DEFAULT_SETTINGS_FORMATTED), StandardCharsets.UTF_8).isFailure())
LOGGER.error("Failed to write metadata to '" + aFile.getAbsolutePath() + "'");
else
LOGGER.info("Wrote metadata to '" + aFile.getAbsolutePath() + "'");
}
});
// Store the outgoings file as well
AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased((eMsgMode, sMessageID, nTry) -> StorageHelper.getStorageFile(sMessageID, nTry, ".as4out")));
}
Aggregations