Skip to content

Instantly share code, notes, and snippets.

@moaschterle
Last active December 19, 2015 21:09
Show Gist options
  • Save moaschterle/6018395 to your computer and use it in GitHub Desktop.
Save moaschterle/6018395 to your computer and use it in GitHub Desktop.
static void Main(string[] args)
{
Console.ReadLine();
//Create a Web-Request to an URL
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://demowebservice.suedtirol.info/service/MOBILEListener");
//Defined poperties for the Web-Request
httpWebRequest.Method = "POST";
httpWebRequest.MediaType = "HTTP/1.1";
httpWebRequest.ContentType = "text/xml";
httpWebRequest.UserAgent = "Example Client";
//Defined data for the Web-Request
byte[] byteArrayData = Encoding.ASCII.GetBytes("method=DocServiceCategorySearch&user=Raysono&pass=PASS&Parameter=" + System.Net.WebUtility.UrlEncode("<Sinfonet><Query><MetaInfo name=\"DocType\" compareMode=\"EQ\">VinaryCustomList</MetaInfo><MetaInfo name=\"DocOwner\" compareMode=\"EQ\">4D84730B51A349FFB68D2140C14456EE</MetaInfo><MetaInfo name=\"DocLang\" compareMode=\"EQ\">DE</MetaInfo></Query><Page number=\"1\" items=\"25\" /><Output dataType=\" * \" dataContext=\" * \" /></Sinfonet>"));
httpWebRequest.ContentLength = byteArrayData.Length;
//Attach data to the Web-Request
Stream dataStream = httpWebRequest.GetRequestStream();
dataStream.Write(byteArrayData, 0, byteArrayData.Length);
dataStream.Close();
//Send Web-Request and receive a Web-Response
HttpWebResponse httpWebesponse = (HttpWebResponse)httpWebRequest.GetResponse();
//Translate data from the Web-Response to a string
dataStream = httpWebesponse.GetResponseStream();
StreamReader streamreader = new StreamReader(dataStream, Encoding.UTF8);
string response = streamreader.ReadToEnd();
streamreader.Close();
Console.WriteLine(response.ToString());
Console.ReadLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment