use of com.helger.phase4.ebms3header.Ebms3Messaging in project phase4 by phax.
the class Ebms3ReaderBuilderTest method testNoSoap.
@Test
public void testNoSoap() {
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler();
final Ebms3Messaging aMessage = Ebms3ReaderBuilder.ebms3Messaging().setValidationEventHandler(aCVEH).read(new ClassPathResource("/soap11test/UserMessage-no-soap.xml"));
assertNotNull(aMessage);
assertTrue(aCVEH.getErrorList().isEmpty());
aMessage.getUserMessageAtIndex(0).getMessageInfo().setMessageId("blaFoo");
final String sReRead = Ebms3WriterBuilder.ebms3Messaging().getAsString(aMessage);
assertNotNull(sReRead);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Just to recheck what was read: " + sReRead);
}
use of com.helger.phase4.ebms3header.Ebms3Messaging in project phase4 by phax.
the class Ebms3ReaderBuilderTest method testSoap.
@Test
public void testSoap() {
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler();
final Soap11Envelope aEnv = Ebms3ReaderBuilder.soap11().setValidationEventHandler(aCVEH).read(new ClassPathResource("/soap11test/UserMessage.xml"));
assertNotNull(aEnv);
assertTrue(aCVEH.getErrorList().isEmpty());
assertNotNull(aEnv.getHeader());
assertEquals(1, aEnv.getHeader().getAnyCount());
assertTrue(aEnv.getHeader().getAnyAtIndex(0) instanceof Element);
final Ebms3Messaging aMessage = Ebms3ReaderBuilder.ebms3Messaging().setValidationEventHandler(aCVEH).read((Element) aEnv.getHeader().getAnyAtIndex(0));
assertNotNull(aMessage);
final String sReRead = Ebms3WriterBuilder.soap11().getAsString(aEnv);
assertNotNull(sReRead);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Just to recheck what was read: " + sReRead);
}
use of com.helger.phase4.ebms3header.Ebms3Messaging in project phase4 by phax.
the class Ebms3MessagingTest method testOnlyEbmsMessaging.
@Test
public void testOnlyEbmsMessaging() throws Exception {
final Ebms3Messaging aEbms3Messaging = new Ebms3Messaging();
final HttpEntity aEntity = new HttpXMLEntity(_getMessagingAsSoapDocument(aEbms3Messaging), SOAP_VERSION.getMimeType());
sendPlainMessage(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.ebms3header.Ebms3Messaging in project phase4 by phax.
the class Ebms3MessagingTest method testUserMessageWithTooManyPartyIds.
@Test
public void testUserMessageWithTooManyPartyIds() throws Exception {
final Ebms3Messaging aEbms3Messaging = new Ebms3Messaging();
final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
// Message Info
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final String sPModeID = SOAP_12_PARTY_ID + "-" + SOAP_12_PARTY_ID;
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = new Ebms3PartyInfo();
// From => Sender
final Ebms3From aEbms3From = new Ebms3From();
aEbms3From.setRole(CAS4.DEFAULT_INITIATOR_URL);
aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3PartyInfo.setFrom(aEbms3From);
// To => Receiver
final Ebms3To aEbms3To = new Ebms3To();
aEbms3To.setRole(CAS4.DEFAULT_RESPONDER_URL);
aEbms3To.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3PartyInfo.setTo(aEbms3To);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
aEbms3UserMessage.setPartyInfo(aEbms3PartyInfo);
aEbms3UserMessage.setPayloadInfo(aEbms3PayloadInfo);
aEbms3UserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
aEbms3Messaging.addUserMessage(aEbms3UserMessage);
final HttpEntity aEntity = new HttpXMLEntity(_getMessagingAsSoapDocument(aEbms3Messaging), SOAP_VERSION.getMimeType());
sendPlainMessage(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.ebms3header.Ebms3Messaging in project phase4 by phax.
the class Ebms3MessagingTest method _getMessagingAsSoapDocument.
@Nullable
private Document _getMessagingAsSoapDocument(@Nonnull final Ebms3Messaging aEbms3Messaging) {
final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(aEbms3Messaging);
if (aEbms3Document == null)
throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
// Creating SOAP 12 Envelope
final Soap12Envelope aSoapEnv = new Soap12Envelope();
aSoapEnv.setHeader(new Soap12Header());
aSoapEnv.setBody(new Soap12Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
Aggregations