using System; using System.Collections.Generic; using System.Windows.Forms; using System.Net; using System.IO; namespace EgekoXmlServiceTest { /* * c# - Beispiel zur Ansteuerung des XML-Dienstes der egeko-Auftrags-Schnittstelle (kurz: 'v2-order') * */ static class Program { static void Main() { HttpWebRequest req = null; string uri = "https://ws.optadata.com/egeko-service-order-v2/xmlservice"; string user = ...; string pass = ...; string requestXml = ""; WebResponse response = null; req = (HttpWebRequest)WebRequest.Create(uri); // Post method req.Method = "POST"; // content type request.ContentType = "text/xml"; // keep alive must be false req.KeepAlive = false; // Authentification request.Credentials = new NetworkCredential(user, pass); request.PreAuthenticate = true; // Wrap the request stream with a text-based writer StreamWriter writer = new StreamWriter(request.GetRequestStream()); // Write the xml text into the stream writer.WriteLine(requestXml); writer.Close(); // Send the data to the webserver response = request.GetResponse(); // Read the response StreamReader reader = new StreamReader(response.GetResponseStream()); string result = reader.ReadToEnd(); reader.Close(); Console.WriteLine(result); } } }