Skip to content

Commit 929bfbf

Browse files
committed
Added new example receiver
1 parent f0bc147 commit 929bfbf

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (C) 2015-2025 Philip Helger (www.helger.com)
3+
* philip[at]helger[dot]com
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.helger.phase4.peppol.receivers;
18+
19+
import java.io.File;
20+
21+
import org.slf4j.Logger;
22+
import org.w3c.dom.Element;
23+
24+
import com.helger.peppol.security.PeppolTrustedCA;
25+
import com.helger.peppol.sml.ESML;
26+
import com.helger.peppolid.IParticipantIdentifier;
27+
import com.helger.phase4.dump.AS4DumpManager;
28+
import com.helger.phase4.dump.AS4IncomingDumperFileBased;
29+
import com.helger.phase4.dump.AS4OutgoingDumperFileBased;
30+
import com.helger.phase4.logging.Phase4LoggerFactory;
31+
import com.helger.phase4.peppol.Phase4PeppolSender;
32+
import com.helger.phase4.sender.EAS4UserMessageSendResult;
33+
import com.helger.servlet.mock.MockServletContext;
34+
import com.helger.smpclient.peppol.SMPClientReadOnly;
35+
import com.helger.web.scope.mgr.WebScopeManager;
36+
import com.helger.xml.serialize.read.DOMReader;
37+
38+
/**
39+
* Example for sending something to the ACT [EG] test endpoint.
40+
*
41+
* @author Philip Helger
42+
*/
43+
public final class MainPhase4PeppolSenderACT
44+
{
45+
private static final Logger LOGGER = Phase4LoggerFactory.getLogger (MainPhase4PeppolSenderACT.class);
46+
47+
public static void main (final String [] args)
48+
{
49+
WebScopeManager.onGlobalBegin (MockServletContext.create ());
50+
51+
// Dump (for debugging purpose only)
52+
AS4DumpManager.setIncomingDumper (new AS4IncomingDumperFileBased ());
53+
AS4DumpManager.setOutgoingDumper (new AS4OutgoingDumperFileBased ());
54+
55+
try
56+
{
57+
final Element aPayloadElement = DOMReader.readXMLDOM (new File ("src/test/resources/external/examples/base-example.xml"))
58+
.getDocumentElement ();
59+
if (aPayloadElement == null)
60+
throw new IllegalStateException ("Failed to read XML file to be send");
61+
62+
// Start configuring here
63+
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("0235:100485671011113");
64+
65+
final EAS4UserMessageSendResult eResult = Phase4PeppolSender.builder ()
66+
.peppolAP_CAChecker (PeppolTrustedCA.peppolTestAP ())
67+
.documentTypeID (Phase4PeppolSender.IF.createDocumentTypeIdentifier ("peppol-doctype-wildcard",
68+
"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:peppol:pint:billing-1@ae-1::2.1"))
69+
.processID (Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme ("urn:peppol:bis:billing"))
70+
.senderParticipantID (Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9915:phase4-test-sender"))
71+
.receiverParticipantID (aReceiverID)
72+
.senderPartyID ("POP000306")
73+
.countryC1 ("AT")
74+
.payload (aPayloadElement)
75+
.smpClient (new SMPClientReadOnly (Phase4PeppolSender.URL_PROVIDER,
76+
aReceiverID,
77+
ESML.DIGIT_TEST))
78+
.sendMessageAndCheckForReceipt ();
79+
LOGGER.info ("Peppol send result: " + eResult);
80+
}
81+
catch (final Exception ex)
82+
{
83+
LOGGER.error ("Error sending Peppol message via AS4", ex);
84+
}
85+
finally
86+
{
87+
WebScopeManager.onGlobalEnd ();
88+
}
89+
}
90+
}

phase4-peppol-client/src/test/java/com/helger/phase4/peppol/receivers/MainPhase4PeppolSenderDT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.helger.xml.serialize.read.DOMReader;
4040

4141
/**
42-
* Example for sending something to the Dataport [DE] test endpoint.
42+
* Example for sending something to the DubaiTrade [AE] test endpoint.
4343
*
4444
* @author Philip Helger
4545
*/

0 commit comments

Comments
 (0)