Process interfacing via an automation system (PLC, PC)
10.8 Remote client
SIMATIC MV420 / SIMATIC MV440
326 Operating Instructions, 04/2013, A5E02371045-06
Pseudocode example
C# Pseudocode XML Backup
// Create new xml file
FileStream newXml = File.O p e n("C:\\mv400para.xml", FileMode.Cr e ate);
// Create http request
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://192.168.0.42/xml/backup.cgi");
myRequest.Method = "GET";
myRequest.ContentLength = 0;
try
{
// Get response
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myRequest.GetResponse();
// Get response stream
Stream streamResponse = myHttpWebResponse.GetResponseStream();
// Read stream and write to file (stream == xml data)
byte[] readBuffer = new byte[256];
int count = streamResponse.Read(readBuffer, 0, readBuffer.GetLength(0));
while (count > 0)
{
newXml.Write(readBuffer, 0, count);
count = streamResponse.Read(readBuffer, 0, readBuffer.GetLength(0));
}
Console.WriteLine("XML backup succeeded.");
}
catch (System.Net.WebException we)
{
Console.WriteLine("NO PERMISSION FOR XML BACKUP!");
}