Welcome to MSDN Blogs Sign in | Join | Help

WER Services

This blog focuses on technologies that support Windows Error Reporting and Windows Quality data.
Using the web services to delete product mappings

In our June release we added web services for deleting mapped product(s), deleting mapped files from a product and deleting a mapped file from multiple products.

The following code sample shows how to delete mapped products.

IMPORTANT: Please use and/or test this code very carefully as this delete cannot be undone. 

The first part of the code is used to login to the web service and get the encrypted token. The second part of the code is for deleting mapped products. The web service for deleting mapped products should be called with a post parameter named "mappedproductid" with a comma separated list of mapped product id's.

Get the mapped product id's from the web service for getting the list of products.

   1:  string baseUrl = "https://winqual.microsoft.com";
   2:  string userName = "your winqual username";
   3:  string password = "your winqual password";
   4:   
   5:  //
   6:  // login
   7:  //
   8:  string loginUrl = string.Format(
   9:      "{0}/services/Authentication/Authentication.svc/BasicTicket"
  10:      , baseUrl);
  11:  string request = string.Format(
  12:      "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><GetBasicTicket xmlns=\"https://winqual.microsoft.com/Services/Authentication/\"><userName>{0}</userName><password>{1}</password></GetBasicTicket></soap:Body></soap:Envelope>"
  13:      , userName
  14:      , password);
  15:  WebClient loginClient = new WebClient();
  16:  loginClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
  17:  loginClient.Headers.Add(
  18:      "SOAPAction",
  19:      "https://winqual.microsoft.com/Services/Authentication/IBasicTicket/GetBasicTicket");
  20:  string loginResponse = loginClient.UploadString(loginUrl, request);
  21:   
  22:  //
  23:  // TODO: Handle condition where the ticket is null in case of bad pwd, bad username or some other error
  24:  //
  25:   
  26:  //
  27:  // parse the response to get the encrypted ticket out
  28:  //
  29:  int startingIndex = loginResponse.IndexOf("<GetBasicTicketResult>") + "<GetBasicTicketResult>".Length;
  30:  int endingIndex = loginResponse.IndexOf("</GetBasicTicketResult>");
  31:  string encryptedTicket = loginResponse.Substring(startingIndex, (endingIndex - startingIndex));
  32:   
  33:  //
  34:  // comma separated list of mapped product id’s (integers) to delete.
  35:  // IMPORTANT: This delete cannot be undone.
  36:  //
  37:   
  38:  string mappedProductIDs = "list of comma separated mapped product id's";
  39:  NameValueCollection nameValueCollection = new NameValueCollection(1);
  40:  nameValueCollection.Add("mappedproductid", mappedProductIDs);
  41:  WebClient webClient = new WebClient();
  42:  webClient.Encoding = Encoding.UTF8;
  43:  webClient.Headers.Add("encryptedTicket", encryptedTicket);
  44:  webClient.UploadValues(baseUrl + "/services/wer/user/deletemappedproducts.aspx", nameValueCollection);

This code will delete the mapped products and these products will look grayed out in the mapped product list at https://winqual.microsoft.com/member/wer/user/ManageProductMappings.aspx.

The code for deleting mapped files for a product and deleting mapped file from multiple products is similar to the code above.

The relative URL for deleting multiple mapped files from a single product is “/member/wer/user/DeleteMappedFilesForProduct.aspx”. This form requires two POST parameters. One is the “mappedproductid” parameter with the id of the mapped product and the second is “mappedfileid” which is the comma seperated list of mapped file id’s to delete.

The relative URL for deleting a single mapped file from multiple products is “/member/wer/user/DeleteMappedFileFromProducts.aspx”. This form requires two POST parameters. One is the “mappedfileid” parameter with the id of the mapped file and the second is “mappedproductid” which is the comma seperated list of mapped product id’s to delete the mapped file id.

Posted: Monday, August 24, 2009 8:18 PM by sunilab

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker