private void InsertUserMessage(string mpc, MessageExchangePattern pattern, Operation operation)
        {
            var sendingPMode = new SendingProcessingMode()
            {
                Id = "SomePModeId",
                MessagePackaging = { Mpc = mpc }
            };

            UserMessage userMessage = SendingPModeMap.CreateUserMessage(sendingPMode);
            AS4Message  as4Message  = AS4Message.Create(userMessage, sendingPMode);

            var om = new OutMessage(userMessage.MessageId)
            {
                MEP             = pattern,
                Mpc             = mpc,
                ContentType     = as4Message.ContentType,
                EbmsMessageType = MessageType.UserMessage,
                Operation       = operation,
                MessageLocation =
                    InMemoryMessageBodyStore.Default.SaveAS4Message(location: "some-location", message: as4Message)
            };

            om.SetPModeInformation(sendingPMode);
            GetDataStoreContext.InsertOutMessage(om);
        }
Пример #2
0
        /// <summary>
        /// Start creating a <see cref="AS4Message" />
        /// </summary>
        /// <param name="messagingContext"></param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            if (messagingContext == null)
            {
                throw new ArgumentNullException(nameof(messagingContext));
            }

            if (messagingContext.AS4Message == null)
            {
                throw new InvalidOperationException(
                          $"{nameof(CreateDefaultAS4MessageStep)} requires an AS4Message to assign the default UserMessage to but no AS4Message is present in the MessagingContext");
            }

            SendingProcessingMode pmode = _config.GetSendingPMode(DefaultPmode);

            IEnumerable <PartInfo> parts =
                messagingContext.AS4Message.Attachments.Select(PartInfo.CreateFor);

            UserMessage userMessage =
                SendingPModeMap.CreateUserMessage(pmode, parts.ToArray());

            messagingContext.AS4Message.AddMessageUnit(userMessage);
            messagingContext.SendingPMode = pmode;

            Logger.Info($"{messagingContext.LogTag} Default AS4Message is created using SendingPMode {pmode.Id}");
            return(await StepResult.SuccessAsync(messagingContext));
        }