Search in sources :

Example 6 with MPC

use of com.helger.phase4.model.mpc.MPC in project phase4 by phax.

the class PullRequestTest method testSendPullRequestTwoSPIsFailure.

@Test
public void testSendPullRequestTwoSPIsFailure() throws Exception {
    final String sMPC = "TWO-SPI";
    final MPC aMPC = new MPC(sMPC);
    if (MetaAS4Manager.getMPCMgr().getMPCOfID(sMPC) == null)
        MetaAS4Manager.getMPCMgr().createMPC(aMPC);
    final Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), sMPC, null).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    sendPlainMessageAndWait(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : MPC(com.helger.phase4.model.mpc.MPC) HttpEntity(org.apache.http.HttpEntity) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 7 with MPC

use of com.helger.phase4.model.mpc.MPC in project phase4 by phax.

the class MockMessageProcessorSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nullable final IPMode aPMode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    // Must be a pull-request
    final Ebms3PullRequest aPullRequest = aSignalMessage.getPullRequest();
    if (aPullRequest != null) {
        if (aPullRequest.getMpc().equals(MPC_FAILURE)) {
            return AS4SignalMessageProcessorResult.createFailure("Error in creating the usermessage - mock MPC 'failure' was used!");
        }
        // Empty MPC
        if (aPullRequest.getMpc().equals(MPC_EMPTY)) {
            return AS4SignalMessageProcessorResult.createSuccess();
        }
    }
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    final Ebms3PartyInfo aEbms3PartyInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
    final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aUserMessage.setMessageInfo(aEbms3MessageInfo);
    aUserMessage.setMessageProperties(aEbms3MessageProperties);
    aUserMessage.setPartyInfo(aEbms3PartyInfo);
    aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
    if (aPullRequest != null)
        aUserMessage.setMpc(aPullRequest.getMpc());
    return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Aggregations

Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)4 HttpEntity (org.apache.http.HttpEntity)4 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)3 HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)3 MPC (com.helger.phase4.model.mpc.MPC)3 Nonnull (javax.annotation.Nonnull)3 Test (org.junit.Test)3 Document (org.w3c.dom.Document)3 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)2 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)2 Ebms3Error (com.helger.phase4.ebms3header.Ebms3Error)2 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)2 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)2 Ebms3PullRequest (com.helger.phase4.ebms3header.Ebms3PullRequest)2 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)2 Phase4Exception (com.helger.phase4.util.Phase4Exception)2 IOException (java.io.IOException)2 Locale (java.util.Locale)2 MessagingException (javax.mail.MessagingException)2 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)2