Skip to content

Instantly share code, notes, and snippets.

@LGM-AdrianHum
Created November 5, 2015 04:46
Show Gist options
  • Save LGM-AdrianHum/cd4d1947d4d96c9af799 to your computer and use it in GitHub Desktop.
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#
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