/// <summary> /// Sends an HTTP request to the DRM DeviceCore service with the given /// data. /// </summary> /// <param name="method">HTTP method.</param> /// <param name="data">Data to send.</param> private void SendDRMRequest(string method, string data) { string user = AppPreferences.GetDRMUsername(); string pwd = AppPreferences.GetDRMPassword(); if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pwd)) { throw new Exception("User and password not configured."); } // Create url to the Remote Manager server for a given web service request. Uri url = new Uri(string.Format("{0}/ws/DeviceCore", AppPreferences.GetDRMServer())); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = method; CredentialCache credCache = new CredentialCache(); credCache.Add(url, "Basic", new NetworkCredential(user, pwd)); request.Credentials = credCache; request.ContentType = "text/xml"; request.Accept = "text/xml"; StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(data); writer.Close(); // Get response. WebResponse serverResponse = request.GetResponse(); serverResponse.Close(); }
/// <summary> /// Class constructor. Instantiates a new <c>DrmCredentialsPage</c> /// object. /// </summary> public DrmCredentialsPage() { InitializeComponent(); BindingContext = this; usernameEntry.Text = AppPreferences.GetDRMUsername(); passwordEntry.Text = AppPreferences.GetDRMPassword(); serverPicker.ItemsSource = new List <string> { "Production", "Test" }; serverPicker.SelectedIndex = AppPreferences.GetDRMServer().Equals(SERVER_PRODUCTION) ? 0 : 1; }