Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jan 29, 2025
1 parent 8c28e66 commit 8ec05af
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2015-2024 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.phase4.peppol.receivers;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;

import com.helger.peppol.sml.ESML;
import com.helger.peppolid.IParticipantIdentifier;
import com.helger.phase4.dump.AS4DumpManager;
import com.helger.phase4.dump.AS4IncomingDumperFileBased;
import com.helger.phase4.dump.AS4OutgoingDumperFileBased;
import com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile;
import com.helger.phase4.peppol.Phase4PeppolSender;
import com.helger.phase4.sender.EAS4UserMessageSendResult;
import com.helger.servlet.mock.MockServletContext;
import com.helger.smpclient.peppol.SMPClientReadOnly;
import com.helger.web.scope.mgr.WebScopeManager;
import com.helger.xml.serialize.read.DOMReader;

/**
* Example for sending something to the acube.io [IT] Test endpoint.
*
* @author Philip Helger
*/
public final class MainPhase4PeppolSenderKontextE
{
private static final Logger LOGGER = LoggerFactory.getLogger (MainPhase4PeppolSenderKontextE.class);

public static void send ()
{
try
{
final Element aPayloadElement = DOMReader.readXMLDOM (new File ("src/test/resources/external/examples/base-example.xml"))
.getDocumentElement ();
if (aPayloadElement == null)
throw new IllegalStateException ("Failed to read XML file to be send");

// Start configuring here
// 0106:32070687
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9930:pnl000734");
final EAS4UserMessageSendResult 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")
.countryC1 ("AT")
.payload (aPayloadElement)
.smpClient (new SMPClientReadOnly (Phase4PeppolSender.URL_PROVIDER,
aReceiverID,
ESML.DIGIT_TEST))
.rawResponseConsumer (new AS4RawResponseConsumerWriteToFile ())
.sendMessageAndCheckForReceipt ();
LOGGER.info ("Peppol send result: " + eResult);
}
catch (final Exception ex)
{
LOGGER.error ("Error sending Peppol message via AS4", ex);
}
}

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
{
send ();
}
finally
{
WebScopeManager.onGlobalEnd ();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void main (final String [] args)
throw new IllegalStateException ("Failed to read XML file to be send");

// Start configuring here
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("0204:07-49849849499-27");
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("0204:07-testbehoerdekober-96");
final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback ()
{
public void onAS4Message (final AbstractAS4Message <?> aMsg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void main (final String [] args)
if (aPayloadElement == null)
throw new IllegalStateException ("Failed to read XML file to be send");

final String sReceiverID = "0204:07-49849849499-27";
final String sReceiverID = "0204:07-testbehoerdekober-96";
final StopWatch aSW = StopWatch.createdStarted ();
final ICommonsMap <String, String> aRcvToMsgIDMap = new CommonsLinkedHashMap <> ();
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cbc:Note>#ADU#Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden.</cbc:Note>
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
<cbc:BuyerReference>04011000-12345-03</cbc:BuyerReference>
<cbc:BuyerReference>10000000-TestbehoerdeKober-45</cbc:BuyerReference>
<cac:AccountingSupplierParty>
<cac:Party>
<cac:PartyName>
Expand Down

0 comments on commit 8ec05af

Please sign in to comment.