public static AckRequested createAckRequested( CollaborationProtocolAgreement cpa, EbMSMessageContext context) { PartyInfo partyInfo = CPAUtils.getSendingPartyInfo( cpa, context.getFromRole(), context.getServiceType(), context.getService(), context.getAction()); DeliveryChannel channel = CPAUtils.getDeliveryChannel( partyInfo .getCollaborationRole() .get(0) .getServiceBinding() .getCanSend() .get(0) .getThisPartyActionBinding()); if (PerMessageCharacteristicsType.ALWAYS.equals( channel.getMessagingCharacteristics().getAckRequested())) { AckRequested ackRequested = new AckRequested(); ackRequested.setVersion(Constants.EBMS_VERSION); ackRequested.setMustUnderstand(true); ackRequested.setSigned( PerMessageCharacteristicsType.ALWAYS.equals( channel.getMessagingCharacteristics().getAckSignatureRequested())); ackRequested.setActor(channel.getMessagingCharacteristics().getActor().value()); return ackRequested; } else return null; }
public static MessageHeader createMessageHeader( CollaborationProtocolAgreement cpa, EbMSMessageContext context, String hostname) throws DatatypeConfigurationException { String uuid = UUID.getUUID(); PartyInfo sendingPartyInfo = CPAUtils.getSendingPartyInfo( cpa, context.getFromRole(), context.getServiceType(), context.getService(), context.getAction()); PartyInfo receivingPartyInfo = CPAUtils.getReceivingPartyInfo( cpa, context.getToRole(), context.getServiceType(), context.getService(), context.getAction()); // PartyInfo receivingPartyInfo = // CPAUtils.getOtherReceivingPartyInfo(cpa,context.getFromRole(),context.getServiceType(),context.getService(),context.getAction()); MessageHeader messageHeader = new MessageHeader(); messageHeader.setVersion(Constants.EBMS_VERSION); messageHeader.setMustUnderstand(true); messageHeader.setCPAId(cpa.getCpaid()); messageHeader.setConversationId( context.getConversationId() != null ? context.getConversationId() : uuid); messageHeader.setFrom(new From()); PartyId from = new PartyId(); from.setType(sendingPartyInfo.getPartyId().get(0).getType()); from.setValue(sendingPartyInfo.getPartyId().get(0).getValue()); messageHeader.getFrom().getPartyId().add(from); messageHeader .getFrom() .setRole(sendingPartyInfo.getCollaborationRole().get(0).getRole().getName()); messageHeader.setTo(new To()); PartyId to = new PartyId(); to.setType(receivingPartyInfo.getPartyId().get(0).getType()); to.setValue(receivingPartyInfo.getPartyId().get(0).getValue()); messageHeader.getTo().getPartyId().add(to); messageHeader .getTo() .setRole(receivingPartyInfo.getCollaborationRole().get(0).getRole().getName()); messageHeader.setService(new Service()); messageHeader .getService() .setType( sendingPartyInfo .getCollaborationRole() .get(0) .getServiceBinding() .getService() .getType()); messageHeader .getService() .setValue( sendingPartyInfo .getCollaborationRole() .get(0) .getServiceBinding() .getService() .getValue()); messageHeader.setAction( sendingPartyInfo .getCollaborationRole() .get(0) .getServiceBinding() .getCanSend() .get(0) .getThisPartyActionBinding() .getAction()); messageHeader.setMessageData(new MessageData()); messageHeader.getMessageData().setMessageId(uuid + "@" + hostname); messageHeader.getMessageData().setRefToMessageId(context.getRefToMessageId()); messageHeader .getMessageData() .setTimestamp( DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar())); ReliableMessaging rm = CPAUtils.getReliableMessaging(cpa, messageHeader); if (rm != null) { GregorianCalendar timestamp = messageHeader.getMessageData().getTimestamp().toGregorianCalendar(); Duration d = rm.getRetryInterval().multiply(rm.getRetries().add(new BigInteger("1")).intValue()); d.addTo(timestamp); timestamp.add(Calendar.SECOND, 1); messageHeader .getMessageData() .setTimeToLive(DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp)); } DeliveryChannel channel = CPAUtils.getDeliveryChannel( sendingPartyInfo .getCollaborationRole() .get(0) .getServiceBinding() .getCanSend() .get(0) .getThisPartyActionBinding()); messageHeader.setDuplicateElimination( PerMessageCharacteristicsType.ALWAYS.equals( channel.getMessagingCharacteristics().getDuplicateElimination()) ? "" : null); return messageHeader; }