private static async Task <AS4Message> BuildMessageFor(byte[] as4MessageExternalPayloads, string contentType)
 {
     using (var stream = new MemoryStream(as4MessageExternalPayloads))
     {
         var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());
         return(await serializer.DeserializeAsync(stream, contentType));
     }
 }
        private static async Task <AS4Message> CreateAS4MessageFrom(byte[] deliveragentMessage)
        {
            var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            return(await serializer.DeserializeAsync(
                       new MemoryStream(deliveragentMessage),
                       ContentType));
        }
示例#3
0
        protected async Task <AS4Message> ExerciseMimeDeserialize(Stream stream, string contentType)
        {
            // Arrange
            var sut = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            // Act
            return(await sut.DeserializeAsync(stream, contentType));
        }
        protected Task <AS4Message> GetEncryptedAS4MessageAsync()
        {
            Stream inputStream = new MemoryStream(as4_encrypted_message);
            var    serializer  = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            return(serializer.DeserializeAsync(
                       inputStream,
                       "multipart/related; boundary=\"MIMEBoundary_64ed729f813b10a65dfdc363e469e2206ff40c4aa5f4bd11\""));
        }
        private static Task <AS4Message> SerializeDeserializeMime(AS4Message msg)
        {
            var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());
            var memory     = new MemoryStream();

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

            return(serializer.DeserializeAsync(memory, msg.ContentType));
        }
        private static async Task <AS4Message> SerializeDeserialize(AS4Message message)
        {
            var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            var memory = new MemoryStream();

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

            return(await serializer.DeserializeAsync(memory, message.ContentType));
        }
        private static async Task <AS4Message> DeserializeToEncryptedMessage(byte[] messageContents, string contentType)
        {
            Stream inputStream = new MemoryStream(messageContents);
            var    serializer  = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            var message = await serializer.DeserializeAsync(
                inputStream,
                contentType);

            Assert.True(message.IsEncrypted, "The AS4 Message to use in this testcase should be encrypted");

            return(message);
        }
        public async Task DeserializeMultihopSignalMessage()
        {
            // Arrange
            const string contentType   = "multipart/related; boundary=\"=-M/sMGEhQK8RBNg/21Nf7Ig==\";\ttype=\"application/soap+xml\"";
            string       messageString = Encoding.UTF8.GetString(as4_multihop_message).Replace((char)0x1F, ' ');

            byte[] messageContent = Encoding.UTF8.GetBytes(messageString);
            using (var messageStream = new MemoryStream(messageContent))
            {
                var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

                // Act
                AS4Message actualMessage = await serializer.DeserializeAsync(messageStream, contentType);

                // Assert
                Assert.True(actualMessage.IsSignalMessage);
            }
        }