PackageUsermessageInfo extends AbstractUserMessageHandler { @Override protected InvocationResponse doProcessing(final IUserMessageEntity um, final IMessageProcessingContext procCtx, final Logger log) { log.trace("Get the eb:Messaging header from the message"); final SOAPHeaderBlock messaging = Messaging.getElement(procCtx.getParentContext().getEnvelope()); log.trace("Add eb:UserMessage element to the existing eb:Messaging header"); UserMessageElement.createElement(messaging, um); log.debug("eb:UserMessage element for User Message [msgId=" + um.getMessageId() + "] succesfully added to header"); return InvocationResponse.CONTINUE; }    }
@Test public void testDoProcessing() throws Exception { UserMessage userMessage = new UserMessage(); userMessage.setMessageId(UUID.randomUUID().toString()); userMessage.setTimestamp(new Date()); TradingPartner sender = new TradingPartner(); sender.addPartyId(new PartyId("TheSender", null)); sender.setRole("Sender"); userMessage.setSender(sender); TradingPartner receiver = new TradingPartner(); receiver.addPartyId(new PartyId("TheRecipient", null)); receiver.setRole("Receiver"); userMessage.setReceiver(receiver); CollaborationInfo collabInfo = new CollaborationInfo(); collabInfo.setService(new Service("PackagingTest")); collabInfo.setAction("Create"); userMessage.setCollaborationInfo(collabInfo); userMessage.addMessageProperty(new Property("some-meta-data", "description")); Payload p = new Payload(); p.setPayloadURI("cid:as_attachment"); p.addProperty(new Property("p1", "v1")); userMessage.addPayload(p); SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12); SOAPHeaderBlock messaging = Messaging.createElement(env); MessageContext mc = new MessageContext(); mc.setFLOW(MessageContext.OUT_FLOW); try { mc.setEnvelope(env); } catch (AxisFault axisFault) { fail(axisFault.getMessage()); } StorageManager updateManager = HolodeckB2BCore.getStorageManager(); IUserMessageEntity userMessageEntity = updateManager.storeIncomingMessageUnit(userMessage); IMessageProcessingContext procCtx = MessageProcessingContext.getFromMessageContext(mc); procCtx.setUserMessage(userMessageEntity); try { assertEquals(Handler.InvocationResponse.CONTINUE, new PackageUsermessageInfo().invoke(mc)); } catch (Exception e) { fail(e.getMessage()); } assertTrue(messaging.getChildElements().hasNext()); OMElement signalElem = (OMElement) messaging.getChildElements().next(); assertEquals("UserMessage", signalElem.getLocalName()); assertEquals(EbMSConstants.EBMS3_NS_URI, signalElem.getNamespaceURI()); assertNotNull(signalElem.getFirstChildWithName(new QName(EbMSConstants.EBMS3_NS_URI, "PartyInfo"))); OMElement msgInfoElem = signalElem.getFirstChildWithName(new QName(EbMSConstants.EBMS3_NS_URI, "MessageInfo")); assertNotNull(msgInfoElem); assertEquals(userMessage.getMessageId(), msgInfoElem.getFirstChildWithName(new QName(EbMSConstants.EBMS3_NS_URI, "MessageId")).getText()); }