internal static void InitializeStream(subscribeAndSend messageBody, MemoryStream stream)
            {
                var namespaces = new XmlSerializerNamespaces();
                namespaces.Add(NAMESPACE_PREFIX, NAMESPACE);

                var serializer = new XmlSerializer(typeof (subscribeAndSend));
                serializer.Serialize(stream, messageBody, namespaces);

                stream.Seek(0, SeekOrigin.Begin);
            }
 public static subscribeAndSend CreateSendAndSubcribeMessage(object messageDto, int messageId)
 {
     var message = new subscribeAndSend
                       {
                           subscriber = CreateSubscriber(messageDto),
                           subscriberMessage = new subscriberMessage {masterId = messageId},
                           sideTable = CreateSideTableArray(messageDto)
                       };
     return message;
 }
        public static string Serialize(subscribeAndSend snsMessage)
        {
            var requestBody = string.Empty;

            using (var stream = new MemoryStream())
            {
                StreamHelper.InitializeStream(snsMessage, stream);
                requestBody = StreamHelper.ReadStream(stream);
            }
            return requestBody;
        }
        public statusType SendEmail(subscribeAndSend subscribeAndSend)
        {
            try
            {
                var requestBody = YesMailSerializer.Serialize(subscribeAndSend);
                var response = MakeRequest(requestBody);

                _logger.Debug("\n\nResponse: \n-----------\n" + response);

                var status = YesMailSerializer.DeserializeStatus(response);
                return status;
            }
            catch (Exception e)
            {
                _logger.Error("\n\nSendEmail Error\n---------------", e);
                throw;
            }
        }