-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXmlApiRequest.cs
52 lines (47 loc) · 1.62 KB
/
XmlApiRequest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
namespace Microsoft.LiveMeeting.RecordingExporter
{
public class XmlApiClient
{
public static XmlDocument PostMessageRequest(XmlDocument requestXml)
{
ASCIIEncoding encoder = new ASCIIEncoding();
XmlDocument replyXml = null;
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(Config.PostingURL);
webReq.Method = "POST";
webReq.ContentType = "application/xml";
HttpWebResponse webResp = null;
try
{
byte[] byteArray = encoder.GetBytes(requestXml.OuterXml);
webReq.ContentLength = byteArray.Length;
Stream reqStream = webReq.GetRequestStream();
reqStream.Write(byteArray, 0, byteArray.Length);
reqStream.Close();
// Get the response from the conference center
webResp = (HttpWebResponse)webReq.GetResponse();
Stream respStream = webResp.GetResponseStream();
if (webResp.ContentType == "application/xml")
{
replyXml = new XmlDocument();
replyXml.Load(respStream);
}
}
catch (Exception e)
{
Debug.WriteLine("Error: {0}\nStack trace: {1}", e.Message, e.StackTrace);
}
finally
{
if (webResp != null)
webResp.Close();
}
return replyXml;
}
}
}