Skip to content

Commit 8ec05af

Browse files
committed
Updated
1 parent 8c28e66 commit 8ec05af

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (C) 2015-2024 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.slf4j.LoggerFactory;
23+
import org.w3c.dom.Element;
24+
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.dump.AS4RawResponseConsumerWriteToFile;
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 acube.io [IT] Test endpoint.
40+
*
41+
* @author Philip Helger
42+
*/
43+
public final class MainPhase4PeppolSenderKontextE
44+
{
45+
private static final Logger LOGGER = LoggerFactory.getLogger (MainPhase4PeppolSenderKontextE.class);
46+
47+
public static void send ()
48+
{
49+
try
50+
{
51+
final Element aPayloadElement = DOMReader.readXMLDOM (new File ("src/test/resources/external/examples/base-example.xml"))
52+
.getDocumentElement ();
53+
if (aPayloadElement == null)
54+
throw new IllegalStateException ("Failed to read XML file to be send");
55+
56+
// Start configuring here
57+
// 0106:32070687
58+
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9930:pnl000734");
59+
final EAS4UserMessageSendResult eResult;
60+
eResult = Phase4PeppolSender.builder ()
61+
.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"))
62+
.processID (Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme ("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"))
63+
.senderParticipantID (Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9915:phase4-test-sender"))
64+
.receiverParticipantID (aReceiverID)
65+
.senderPartyID ("POP000306")
66+
.countryC1 ("AT")
67+
.payload (aPayloadElement)
68+
.smpClient (new SMPClientReadOnly (Phase4PeppolSender.URL_PROVIDER,
69+
aReceiverID,
70+
ESML.DIGIT_TEST))
71+
.rawResponseConsumer (new AS4RawResponseConsumerWriteToFile ())
72+
.sendMessageAndCheckForReceipt ();
73+
LOGGER.info ("Peppol send result: " + eResult);
74+
}
75+
catch (final Exception ex)
76+
{
77+
LOGGER.error ("Error sending Peppol message via AS4", ex);
78+
}
79+
}
80+
81+
public static void main (final String [] args)
82+
{
83+
WebScopeManager.onGlobalBegin (MockServletContext.create ());
84+
85+
// Dump (for debugging purpose only)
86+
AS4DumpManager.setIncomingDumper (new AS4IncomingDumperFileBased ());
87+
AS4DumpManager.setOutgoingDumper (new AS4OutgoingDumperFileBased ());
88+
89+
try
90+
{
91+
send ();
92+
}
93+
finally
94+
{
95+
WebScopeManager.onGlobalEnd ();
96+
}
97+
}
98+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void main (final String [] args)
6262
throw new IllegalStateException ("Failed to read XML file to be send");
6363

6464
// Start configuring here
65-
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("0204:07-49849849499-27");
65+
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("0204:07-testbehoerdekober-96");
6666
final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback ()
6767
{
6868
public void onAS4Message (final AbstractAS4Message <?> aMsg)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static void main (final String [] args)
6565
if (aPayloadElement == null)
6666
throw new IllegalStateException ("Failed to read XML file to be send");
6767

68-
final String sReceiverID = "0204:07-49849849499-27";
68+
final String sReceiverID = "0204:07-testbehoerdekober-96";
6969
final StopWatch aSW = StopWatch.createdStarted ();
7070
final ICommonsMap <String, String> aRcvToMsgIDMap = new CommonsLinkedHashMap <> ();
7171
try

phase4-peppol-client/src/test/resources/external/examples/xrechnung-2.3.1-ubl-inv.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
2727
<cbc:Note>#ADU#Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden.</cbc:Note>
2828
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
29-
<cbc:BuyerReference>04011000-12345-03</cbc:BuyerReference>
29+
<cbc:BuyerReference>10000000-TestbehoerdeKober-45</cbc:BuyerReference>
3030
<cac:AccountingSupplierParty>
3131
<cac:Party>
3232
<cac:PartyName>

0 commit comments

Comments
 (0)