Search in sources :

Example 1 with Ebms3Messaging

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);
}
Also used : CollectingValidationEventHandler(com.helger.jaxb.validation.CollectingValidationEventHandler) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 2 with Ebms3Messaging

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);
}
Also used : Soap11Envelope(com.helger.phase4.soap11.Soap11Envelope) CollectingValidationEventHandler(com.helger.jaxb.validation.CollectingValidationEventHandler) Element(org.w3c.dom.Element) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 3 with Ebms3Messaging

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());
}
Also used : HttpEntity(org.apache.http.HttpEntity) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Test(org.junit.Test)

Example 4 with Ebms3Messaging

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());
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) HttpEntity(org.apache.http.HttpEntity) Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 5 with Ebms3Messaging

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);
}
Also used : Soap12Envelope(com.helger.phase4.soap12.Soap12Envelope) Soap12Header(com.helger.phase4.soap12.Soap12Header) Soap12Body(com.helger.phase4.soap12.Soap12Body) Document(org.w3c.dom.Document) Nullable(javax.annotation.Nullable)

Aggregations

Ebms3Messaging (com.helger.phase4.ebms3header.Ebms3Messaging)9 Test (org.junit.Test)8 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)6 CollectingValidationEventHandler (com.helger.jaxb.validation.CollectingValidationEventHandler)5 HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)4 HttpEntity (org.apache.http.HttpEntity)4 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)3 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)3 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)3 Soap11Envelope (com.helger.phase4.soap11.Soap11Envelope)3 Element (org.w3c.dom.Element)3 Ebms3From (com.helger.phase4.ebms3header.Ebms3From)2 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)2 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)2 Ebms3PullRequest (com.helger.phase4.ebms3header.Ebms3PullRequest)2 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)2 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)2 Node (org.w3c.dom.Node)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)1 IError (com.helger.commons.error.IError)1