Applies To:
  • CitectSCADA
  • CitectHMI
  • CitectSCADA Pocket Versions

Summary:
How do I use XML Web Services with CitectSCADA?
 

Solution:
Simple as possible example of using XML Web Services with CitectSCADA

Prerequisites

  1. IIS installed on your system (Internet Information Services, ie the Windows web server)
  2. CitectSCADA V6.10 installed on your system

Installing and testing the Web Service

  1. Run the CitectSCADA V6.10 installer (CitectSCADA Setup.msi) selecting the CitectSCADA pocket option

  1. Choose next then select only the pocket server option

  1. Complete the rest of the installation
  2. This will have installed a new website on your IIS (ctAPIWebService). This can be viewed by going to Control Panel / Administrative Tools / Internet Information Services.

  1. To confirm it is running correctly, right click on the CtApiService.asmx file and select browse. This should open the page in IE which describes the methods supported by the CtAPIService.

  1. If you receive an error at this point, it may be resolved by running the dot net framework 2.0 installer and choosing the repair option. Test again to confirm you can see the page as above.
  2. At this point the Web Service is installed and should be operational. Run up the Example project. Then from the web page above choose the WebCtMultiTagReadEx link. Type the name of a tag from the project (eg LOOP_1_SP) then select invoke. A new webpage should open which contains the value of the tag amongst some XML code.

Using the Web Service

  1. The following example will be a VB application created using Visual Studio 2005. However there are many ways of utilising the Web Service. Web Services in an open internet standard which is designed to be platform independent.
  2. Start Visual Studio 2005. Create a new project (File / New / Project)
  3. Select the type as Visual Basic \ Windows \ Windows Application and name it SAPP_Citect_WebServices.

  1. Right click the project and select Add Web Reference.

  1. Select browse to: Web services on the local machine. Then choose CtApiService. You should see in this dialog the same web page as you saw in step 5 of the last section.. Give the web reference a name (‘Citect’ was used in this example) and click Add reference.
  2. The Web reference is now available for use in your project. Right click on it and select view in object browser.

  1. Use the object browser to browse the methods available in the CtAPIService class.

  1. Switch to the Form1.vb [design] tab. From the toolbox (in the left toolbar) add a button and two textbox’s to the form (drag and drop).
  2. Double click on the button, this will take you to the code for Form1. Underneath the first line which says Public Class Form1. Type

Dim CtApiWebService As New Citect.CtApiService

To make a new instance of the CtApiService Object.

  1. In the Button1_Click subroutine, add the following

Me.TextBox2.Text=CtApiWebService.WebCtMultiTagReadEx(Me.TextBox1.Text)

  1. Click on the green “Play” triangle in the toolbar to debug your application (this will run the program). The form should display.
  2. Enter the name of a tag in the first textbox (eg LOOP_1_SP), Click on the button. The value of the tag should appear in the second textbox.

  1. There you have it!
 

Keywords:
 

Attachments