Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. private void geraXML()
  2. {
  3. XmlDocument xmlDoc = new XmlDocument();
  4. xmlDoc.PreserveWhitespace = true;
  5. string xml = @"<?xml version=""1.0""?>...";
  6.  
  7. xmlDoc.LoadXml(xml);
  8. string caminho = path/+"xmldoc.xml";
  9. string nomeArquivo = "xmldoc.xml";
  10. xmlDoc.Save(caminho);
  11.  
  12. //call method to generate hash
  13. geraHASH(caminho, nomeArquivo);
  14. }
  15.  
  16. private void enviaACCS001(string protocolo, string caminho)
  17. {
  18. string base64 = Convert.ToBase64String(Encoding.Default.GetBytes("user:password"));
  19. string authorization = String.Concat("Basic ", base64);
  20.  
  21. String finalResult;
  22. HttpWebRequest hwrRequest = (HttpWebRequest)HttpWebRequest.Create("addres/" + protocolo);
  23.  
  24. hwrRequest.UseDefaultCredentials = true;
  25. hwrRequest.Headers.Add("Authorization", authorization);
  26. hwrRequest.Method = "PUT";
  27.  
  28. string finalXML = @"<?xml version=""1.0""?>...";
  29. byte[] bytes = Encoding.Default.GetBytes(finalXML);
  30. hwrRequest.ContentLength = bytes.Length;
  31.  
  32. using (Stream putStream = hwrRequest.GetRequestStream())
  33. {
  34. putStream.Write(bytes, 0, bytes.Length);
  35. }
  36.  
  37. using (HttpWebResponse response = (HttpWebResponse)hwrRequest.GetResponse())
  38. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  39. {
  40. finalResult = reader.ReadToEnd();
  41. visualiza.Text = visualiza.Text + "n " + finalResult;
  42. }
  43.  
  44. private void geraXML()
  45. {
  46. XmlDocument xmlDoc = new XmlDocument();
  47. xmlDoc.PreserveWhitespace = true;
  48. string xml = @"<?xml version=""1.0"" encoding=""UTF-16BE""?>...";
  49.  
  50. xmlDoc.LoadXml(xml);
  51. string caminho = path/+"xmldoc.xml";
  52. string nomeArquivo = "xmldoc.xml";
  53. xmlDoc.Save(caminho);
  54.  
  55. //call method to generate hash
  56. geraHASH(caminho, nomeArquivo);
  57. }
  58.  
  59. private void enviaACCS001(string protocolo, string caminho)
  60. {
  61. string base64 = Convert.ToBase64String(Encoding.Default.GetBytes("user:password"));
  62. string authorization = String.Concat("Basic ", base64);
  63.  
  64. String finalResult;
  65. HttpWebRequest hwrRequest = (HttpWebRequest)HttpWebRequest.Create("addres/" + protocolo);
  66.  
  67. hwrRequest.UseDefaultCredentials = true;
  68. hwrRequest.Headers.Add("Authorization", authorization);
  69. hwrRequest.Method = "PUT";
  70.  
  71. string finalXML = @"<?xml version=""1.0"" encoding=""UTF-16BE""?>...";
  72. byte[] bytes = Encoding.Default.GetBytes(finalXML);
  73. hwrRequest.ContentLength = bytes.Length;
  74.  
  75. using (Stream putStream = hwrRequest.GetRequestStream())
  76. {
  77. putStream.Write(bytes, 0, bytes.Length);
  78. }
  79.  
  80. using (HttpWebResponse response = (HttpWebResponse)hwrRequest.GetResponse())
  81. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  82. {
  83. finalResult = reader.ReadToEnd();
  84. visualiza.Text = visualiza.Text + "n " + finalResult;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement