Simple as possible example of using XML
Web Services with CitectSCADA
Prerequisites
- IIS installed on your system (Internet Information Services, ie
the Windows web server)
- CitectSCADA V6.10 installed on your system
Installing and testing the Web Service
- Run the CitectSCADA V6.10 installer (CitectSCADA Setup.msi)
selecting the CitectSCADA pocket option
- Choose next then select only the pocket server option
- Complete the rest of the installation
- 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.
- 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.
- 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.
- 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
- 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.
- Start Visual Studio 2005. Create a new project (File / New /
Project)
- Select the type as Visual Basic \ Windows \ Windows Application
and name it SAPP_Citect_WebServices.
- Right click the project and select Add Web Reference.
- 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.
- The Web reference is now available for use in your project.
Right click on it and select view in object browser.
- Use the object browser to browse the methods available in the
CtAPIService class.
- 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).
- 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.
- In the Button1_Click
subroutine, add the following
Me.TextBox2.Text=CtApiWebService.WebCtMultiTagReadEx(Me.TextBox1.Text)
- Click on the green “Play” triangle in the toolbar to debug your
application (this will run the program). The form should
display.
- 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.
- There you have it!
|