-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
...client/src/test/java/com/helger/phase4/peppol/receivers/MainPhase4PeppolSenderPrimer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (C) 2015-2023 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.client.IAS4ClientBuildMessageCallback; | ||
import com.helger.phase4.dump.AS4DumpManager; | ||
import com.helger.phase4.dump.AS4IncomingDumperFileBased; | ||
import com.helger.phase4.dump.AS4OutgoingDumperFileBased; | ||
import com.helger.phase4.messaging.domain.AS4UserMessage; | ||
import com.helger.phase4.messaging.domain.AbstractAS4Message; | ||
import com.helger.phase4.peppol.Phase4PeppolSender; | ||
import com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult; | ||
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 Governikus [DE] test endpoint. | ||
* | ||
* @author Philip Helger | ||
*/ | ||
public final class MainPhase4PeppolSenderPrimer | ||
{ | ||
private static final Logger LOGGER = LoggerFactory.getLogger (MainPhase4PeppolSenderPrimer.class); | ||
|
||
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/external/examples/InvoiceResponse_Example.xml")) | ||
.getDocumentElement (); | ||
if (aPayloadElement == null) | ||
throw new IllegalStateException ("Failed to read XML file to be send"); | ||
|
||
// Start configuring here | ||
// Alternative one: 0204:gov06test-85 | ||
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9933:800566476"); | ||
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:ApplicationResponse-2::ApplicationResponse##urn:fdc:peppol.eu:poacc:trns:invoice_response:3::2.1")) | ||
.processID (Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme ("urn:fdc:peppol.eu:poacc:bis:invoice_response:3")) | ||
.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)) | ||
.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 (); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
phase4-peppol-client/src/test/resources/external/examples/InvoiceResponse_Example.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Content: | ||
This file contains a Full BIS3 PEPPOL UBL Invoice Response. | ||
Errors: | ||
None | ||
Warnings: | ||
None | ||
--> | ||
<ApplicationResponse xmlns="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" | ||
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" | ||
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"> | ||
<cbc:CustomizationID>urn:fdc:peppol.eu:poacc:trns:invoice_response:3</cbc:CustomizationID> | ||
<cbc:ProfileID>urn:fdc:peppol.eu:poacc:bis:invoice_response:3</cbc:ProfileID> | ||
<cbc:ID>imrid001</cbc:ID> | ||
<cbc:IssueDate>2017-12-01</cbc:IssueDate> | ||
<cbc:IssueTime>12:00:00</cbc:IssueTime> | ||
<cbc:Note>text</cbc:Note> | ||
<cac:SenderParty> | ||
<cbc:EndpointID schemeID="0088">5798000012349</cbc:EndpointID> | ||
<cac:PartyIdentification> | ||
<cbc:ID schemeID="0184">DK88776655</cbc:ID> | ||
</cac:PartyIdentification> | ||
<cac:PartyLegalEntity> | ||
<cbc:RegistrationName>Buyer organization</cbc:RegistrationName> | ||
</cac:PartyLegalEntity> | ||
<cac:Contact> | ||
<cbc:Name>Jens Jensen</cbc:Name> | ||
<cbc:Telephone>23232323</cbc:Telephone> | ||
<cbc:ElectronicMail>[email protected]</cbc:ElectronicMail> | ||
</cac:Contact> | ||
</cac:SenderParty> | ||
<cac:ReceiverParty> | ||
<cbc:EndpointID schemeID="0088">7330001000000</cbc:EndpointID> | ||
<cac:PartyIdentification> | ||
<cbc:ID schemeID="0192">987654325</cbc:ID> | ||
</cac:PartyIdentification> | ||
<cac:PartyLegalEntity> | ||
<cbc:RegistrationName>Seller company</cbc:RegistrationName> | ||
</cac:PartyLegalEntity> | ||
</cac:ReceiverParty> | ||
<cac:DocumentResponse> | ||
<cac:Response> | ||
<cbc:ResponseCode>RE</cbc:ResponseCode> | ||
<cbc:EffectiveDate>2018-09-24</cbc:EffectiveDate> | ||
<cac:Status> | ||
<cbc:StatusReasonCode listID="OPStatusAction">NOA</cbc:StatusReasonCode> | ||
<cbc:StatusReason>VAT Reference not found</cbc:StatusReason> | ||
<cac:Condition> | ||
<cbc:AttributeID>BT-48</cbc:AttributeID> | ||
<cbc:Description>EU123456789</cbc:Description> | ||
</cac:Condition> | ||
</cac:Status> | ||
</cac:Response> | ||
<cac:DocumentReference> | ||
<cbc:ID>inv021</cbc:ID> | ||
<cbc:IssueDate>2018-09-22</cbc:IssueDate> | ||
<cbc:DocumentTypeCode>380</cbc:DocumentTypeCode> | ||
</cac:DocumentReference> | ||
<cac:IssuerParty> | ||
<cac:PartyIdentification> | ||
<cbc:ID schemeID="0192">123456785</cbc:ID> | ||
</cac:PartyIdentification> | ||
<cac:PartyName> | ||
<cbc:Name>Test Company AS</cbc:Name> | ||
</cac:PartyName> | ||
</cac:IssuerParty> | ||
</cac:DocumentResponse> | ||
</ApplicationResponse> |