use of com.helger.phase4.soap11.Soap11Envelope 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.soap11.Soap11Envelope in project phase4 by phax.
the class AbstractAS4Message method getAsSoapDocument.
@Nonnull
public final Document getAsSoapDocument(@Nullable final Node aPayload) {
// Convert to DOM Node
final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(m_aMessaging);
if (aEbms3Document == null)
throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
final Node aRealPayload = aPayload instanceof Document ? ((Document) aPayload).getDocumentElement() : aPayload;
switch(m_eSoapVersion) {
case SOAP_11:
{
// Creating SOAP 11 Envelope
final Soap11Envelope aSoapEnv = new Soap11Envelope();
aSoapEnv.setHeader(new Soap11Header());
aSoapEnv.setBody(new Soap11Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
if (aRealPayload != null)
aSoapEnv.getBody().addAny(aRealPayload);
return Ebms3WriterBuilder.soap11().getAsDocument(aSoapEnv);
}
case SOAP_12:
{
// Creating SOAP 12 Envelope
final Soap12Envelope aSoapEnv = new Soap12Envelope();
aSoapEnv.setHeader(new Soap12Header());
aSoapEnv.setBody(new Soap12Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
if (aRealPayload != null)
aSoapEnv.getBody().addAny(aRealPayload);
return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
default:
throw new IllegalStateException("Unsupported SOAP version " + m_eSoapVersion);
}
}
use of com.helger.phase4.soap11.Soap11Envelope in project phase4 by phax.
the class Ebms3ReaderBuilderTest method testUserMessageMessageInfoIDMissing.
@Test
public void testUserMessageMessageInfoIDMissing() {
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler();
final Soap11Envelope aEnv = Ebms3ReaderBuilder.soap11().setValidationEventHandler(aCVEH).read(new ClassPathResource("/soap11test/MessageInfoIDMissing.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));
assertTrue(aCVEH.getErrorList().containsAtLeastOneError());
assertNull(aMessage);
}
use of com.helger.phase4.soap11.Soap11Envelope in project phase4 by phax.
the class Ebms3ReaderBuilderTest method testUserMessageMessageInfoMissing.
@Test
public void testUserMessageMessageInfoMissing() {
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler();
final Soap11Envelope aEnv = Ebms3ReaderBuilder.soap11().setValidationEventHandler(aCVEH).read(new ClassPathResource("/soap11test/MessageInfoMissing.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));
assertTrue(aCVEH.getErrorList().containsAtLeastOneError());
assertNull(aMessage);
}
use of com.helger.phase4.soap11.Soap11Envelope in project phase4 by phax.
the class Ebms3ReaderBuilderTest method testExpectSoap11ButFileIsSoap12.
@Test
public void testExpectSoap11ButFileIsSoap12() {
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler();
final Soap11Envelope aEnv = Ebms3ReaderBuilder.soap11().setValidationEventHandler(aCVEH).read(new ClassPathResource("/soap12test/UserMessage12.xml"));
assertNull(aEnv);
assertFalse(aCVEH.getErrorList().isEmpty());
}
Aggregations