Created
November 5, 2015 04:46
-
-
Save LGM-AdrianHum/cd4d1947d4d96c9af799 to your computer and use it in GitHub Desktop.
This is the brute force way of making an XmlRpc call in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void MakeXmlRpcCallTheHardWay() | |
{ | |
byte[] requestData = Encoding.ASCII.GetBytes("<?xml version=\"1.0\"?><methodCall><methodName>Bugzilla.version</methodName></methodCall>"); | |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://bugzilla.mozilla.org/xmlrpc.cgi"); | |
request.Method = "POST"; | |
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729;)"; | |
request.ContentType = "text/xml"; | |
request.ContentLength = requestData.Length; | |
using (Stream requestStream = request.GetRequestStream()) | |
requestStream.Write(requestData, 0, requestData.Length); | |
string result = null; | |
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | |
{ | |
using (Stream stream = response.GetResponseStream()) | |
{ | |
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII)) | |
result = reader.ReadToEnd(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment