Invensys Wonderware System Platform altında SOAP web servislerinin çağrılması

   System Platform altında script ile web servislerini çağıran kod örneğidir. Bir symbol altında kullanarak InTouch tarafında kullanıyoruz. Çalışması için standart .Net kütüphanelerinin import edilmesi gereklidir.

System.Windows.Forms.MessageBox.Show("Started", "Debug");

dim strWsUrl as string;
strWsUrl = "http://SERVER_ADDRESS:PORT/WEBSERVICE/services/WebService";

dim webRequest as System.Net.HttpWebRequest;
webRequest  = System.Net.WebRequest.Create(strWsUrl);

System.Windows.Forms.MessageBox.Show("1", "Debug");
webRequest.Headers.Add("SOAPAction", "login");
webRequest.ContentType = "text/xml;charset=""utf-8""";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
webRequest.UseDefaultCredentials = True;

System.Windows.Forms.MessageBox.Show("2", "Debug");
Dim body As String;
body = "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:web=""http://web.ias.com""> " +
   "<soapenv:Header/>" +
   "<soapenv:Body> " +
      "<web:login soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" +
         "<p_strClient xsi:type=""xsd:string"">
PARAMETER_1</p_strClient>" +
         "<p_strLanguage xsi:type=""xsd:string"">
PARAMETER_2</p_strLanguage>" +
         "<p_strDBName xsi:type=""xsd:string"">PARAMETER_3</p_strDBName>" +
         "<p_strDBServer xsi:type=""xsd:string"">
PARAMETER_4</p_strDBServer>" +
         "<p_strAppServer xsi:type=""xsd:string"">
PARAMETER_5</p_strAppServer>" +
         "<p_strUserName xsi:type=""xsd:string"">
PARAMETER_6</p_strUserName>" +
         "<p_strPassword xsi:type=""xsd:string"">
PARAMETER_7</p_strPassword>" +
      "</web:login>" +
   "</soapenv:Body>" +
"</soapenv:Envelope>";

System.Windows.Forms.MessageBox.Show("3", "Debug");
Dim sw As System.IO.StreamWriter;
sw = System.IO.StreamWriter(webRequest.GetRequestStream());
sw.Write(body);
sw.Dispose();

System.Windows.Forms.MessageBox.Show("4", "Debug");
Dim webResponse As System.Net.WebResponse;
webResponse = webRequest.GetResponse();
System.Windows.Forms.MessageBox.Show("5", "Debug");
Dim rd As System.IO.StreamReader;
rd = new System.IO.StreamReader(webResponse.GetResponseStream());
System.Windows.Forms.MessageBox.Show(rd.ReadToEnd());
webResponse.Close();

System.Windows.Forms.MessageBox.Show("OK", "Debug");

Yorumlar

Bu blogdaki popüler yayınlar

DevExpress ve Telerik karşılaştırması

Install Remmina on macOS for easy connection to your servers via SSH, RDP, VNC.

Logo Apps Eğitim Notları