OpenSRS Lookup Code

string Server = "https://rr-n1-tor.opensrs.net";


string Port = "55443";

string PostData = " <?xml version='1.0' encoding='UTF-8' standalone='no' ?> " + "<!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'> " + " <OPS_envelope> " + " <header>" + " <version>0.9</version> " + " </header> " + " <body>" + " <data_block>" + " <dt_assoc> " + " <item key="protocol">XCP</item>" + " <item key="action">LOOKUP</item>" + " <item key="object">DOMAIN</item>" + " <item key="registrant_ip">" + Request.ServerVariables("LOCAL_ADDR").ToString() + "</item>" + " <item key="attributes">" + "<dt_assoc>" + " <item key="domain">" + Domain.Text + "</item>" + " <item key="no_cache">0</item>" + "</dt_assoc> " + "</item>" + "</dt_assoc>" + "</data_block>" + "</body>" + "</OPS_envelope>";

WebRequest aRequest = WebRequest.Create(Server + ":" + Port);

aRequest.Method = "POST";
aRequest.ContentType = "text/xml";

aRequest.Headers.Add("X-Username", "validuser");

MD5 aMD5 = MD5.Create();

string privateKey = "validkey";

// Dim pkByte() As Byte = aMD5.ComputeHash(PostData & privateKey)
aRequest.Headers.Add("X-Signature", cMD5(cMD5(PostData.ToString() + privateKey) + privateKey));

System.Text.ASCIIEncoding bodyEnc = new System.Text.ASCIIEncoding();

byte[] bodyData = bodyEnc.GetBytes(PostData.ToString());
aRequest.ContentLength = bodyData.Length;

System.IO.Stream aStream = aRequest.GetRequestStream();

aStream.Write(bodyData, 0, bodyData.Length);
aStream.Close();
aStream.Dispose();

//Error Here
WebResponse aResponse = aRequest.GetResponse();

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.