private static Task <AS4Message> SerializeDeserializeSoap(AS4Message msg)
        {
            var serializer = new SoapEnvelopeSerializer();
            var memory     = new MemoryStream();

            serializer.Serialize(msg, memory);
            memory.Position = 0;

            return(serializer.DeserializeAsync(memory, msg.ContentType));
        }
Beispiel #2
0
        protected XmlDocument SerializeSoapMessage(AS4Message message, MemoryStream soapStream)
        {
            ISerializer serializer = new SoapEnvelopeSerializer();

            serializer.Serialize(message, soapStream);

            soapStream.Position = 0;
            var document = new XmlDocument();

            document.Load(soapStream);

            return(document);
        }
Beispiel #3
0
        private async Task CorrectHandlingOnSynchronouslyReceivedMultiHopReceipt(
            bool actAsIntermediaryMsh,
            string receivePModeId,
            OutStatus expectedOutStatus,
            Operation expectedSignalOperation)
        {
            // Arrange
            SendingProcessingMode pmode             = CreateMultihopPMode(StubListenLocation);
            UserMessage           simpleUserMessage = CreateMultihopUserMessage(receivePModeId, pmode);

            AS4Message as4Message = AS4Message.Create(simpleUserMessage, pmode);

            var signal     = new ManualResetEvent(false);
            var serializer = new SoapEnvelopeSerializer();

            StubHttpServer.StartServer(
                StubListenLocation,
                res =>
            {
                res.StatusCode  = 200;
                res.ContentType = Constants.ContentTypes.Soap;

                var receipt = Receipt.CreateFor(
                    $"receipt-{Guid.NewGuid()}",
                    as4Message.FirstUserMessage,
                    userMessageSendViaMultiHop: true);

                serializer.Serialize(AS4Message.Create(receipt), res.OutputStream);
            },
                signal);

            // Act
            PutMessageToSend(as4Message, pmode, actAsIntermediaryMsh);

            // Assert
            signal.WaitOne();

            OutMessage sentMessage = await PollUntilPresent(
                () => _databaseSpy.GetOutMessageFor(m => m.EbmsMessageId == simpleUserMessage.MessageId),
                timeout : TimeSpan.FromSeconds(10));

            Assert.Equal(expectedOutStatus, sentMessage.Status.ToEnum <OutStatus>());

            InMessage receivedMessage = await PollUntilPresent(
                () => _databaseSpy.GetInMessageFor(m => m.EbmsRefToMessageId == simpleUserMessage.MessageId),
                timeout : TimeSpan.FromSeconds(10));

            Assert.Equal(MessageType.Receipt, receivedMessage.EbmsMessageType);
            Assert.Equal(expectedSignalOperation, receivedMessage.Operation);
        }
            public void ThenMpcAttributeIsCorrectlySerialized()
            {
                var userMessage = new UserMessage("some-message-id", "the-specified-mpc");
                var as4Message  = AS4Message.Create(userMessage);

                using (var messageStream = new MemoryStream())
                {
                    var sut = new SoapEnvelopeSerializer();

                    // Act
                    sut.Serialize(as4Message, messageStream);

                    // Assert
                    messageStream.Position = 0;
                    var xmlDocument = new XmlDocument();
                    xmlDocument.Load(messageStream);

                    var userMessageNode = xmlDocument.SelectSingleNode("//*[local-name()='UserMessage']");
                    Assert.NotNull(userMessageNode);
                    Assert.Equal(userMessage.Mpc, userMessageNode.Attributes["mpc"].InnerText);
                }
            }