private static NotificationResponse SendMessage(string strUri, byte[] message, NotificationType notificationType)
        {
            NotificationResponse notResponse = new NotificationResponse();
            Uri uri = new Uri(strUri);

            var request = (HttpWebRequest)WebRequest.Create(uri);

            request.Method        = WebRequestMethods.Http.Post;
            request.ContentType   = "text/xml";
            request.ContentLength = message.Length;

            request.Headers.Add("X-MessageID", Guid.NewGuid().ToString());

            switch (notificationType)
            {
            case NotificationType.Toast:
                request.Headers["X-WindowsPhone-Target"] = "toast";
                request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.ToastImmediately).ToString());
                break;

            case NotificationType.Tile:
                request.Headers["X-WindowsPhone-Target"] = "token";
                request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.TileImmediately).ToString());
                break;

            default:
                request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.RawImmediately).ToString());
                break;
            }

            try
            {
                using (var requestStream = request.GetRequestStream())
                {
                    requestStream.Write(message, 0, message.Length);
                }
                var response = (HttpWebResponse)request.GetResponse();

                var notificationStatus     = response.Headers["X-NotificationStatus"];
                var subscriptionStatus     = response.Headers["X-SubscriptionStatus"];
                var deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];

                notResponse.NotificationStatus     = notificationStatus;
                notResponse.SubscriptionStatus     = subscriptionStatus;
                notResponse.DeviceConnectionStatus = deviceConnectionStatus;
            }
            catch (WebException ex)
            {
                notResponse.DeviceConnectionStatus = ex.ToString();
            }
            return(notResponse);
        }
        private static NotificationResponse SendMessage(string strUri, byte[] message, NotificationType notificationType)
        {
            NotificationResponse notResponse = new NotificationResponse();
            Uri uri = new Uri(strUri);

            var request = (HttpWebRequest)WebRequest.Create(uri);
            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "text/xml";
            request.ContentLength = message.Length;

            request.Headers.Add("X-MessageID", Guid.NewGuid().ToString());

            switch (notificationType)
            {
                case NotificationType.Toast:
                    request.Headers["X-WindowsPhone-Target"] = "toast";
                    request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.ToastImmediately).ToString());
                    break;
                case NotificationType.Tile:
                    request.Headers["X-WindowsPhone-Target"] = "token";
                    request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.TileImmediately).ToString());
                    break;
                default:
                    request.Headers.Add("X-NotificationClass", ((int)BatchingInterval.RawImmediately).ToString());
                    break;
            }

            try
            {
                using (var requestStream = request.GetRequestStream())
                {
                    requestStream.Write(message, 0, message.Length);
                }
                var response = (HttpWebResponse)request.GetResponse();

                var notificationStatus = response.Headers["X-NotificationStatus"];
                var subscriptionStatus = response.Headers["X-SubscriptionStatus"];
                var deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];

                notResponse.NotificationStatus = notificationStatus;
                notResponse.SubscriptionStatus = subscriptionStatus;
                notResponse.DeviceConnectionStatus = deviceConnectionStatus;
            }
            catch (WebException ex)
            {
                notResponse.DeviceConnectionStatus = ex.ToString();
            }
            return notResponse;
        }