Sending data to E3 via .NET web services.

1) Introduction

The Internet as a means of communication used to be limited by the lack of integration between its several environments. The interoperability between different platforms is a very important feature nowadays; in order to integrate these existing environments, the need for a standard of communication emerged. The next logical step in the evolution of this need was the creation of web services, which empowered distributed development, a very important characteristic of the Internet.

2) What are web services?

Web services are the basis of distributed computing on the Internet.  A web service’s client can call any operation offered by this service. The service provider, that is, the application implementing the web service, can be either in the same machine as the service being used or anywhere else on the Internet. Web services use default web protocols, such as XML, SOAP, and HTTP.

XML language is used to represent and transmit structured data, and does not depend on hardware, on software, or even on programming language. SOAP protocol supplies the semantics for data exchange between provider and client.  WSDL language describes the services available by the web service.

To maintain interoperability, web services standardization are kept by W3C [1], OASIS [2], and WS-I [3]. For further information on web services, please refer to the article “Understanding Web Services”, published by Microsoft [4].

3) Elipse WebService driver

Elipse WebService driver, integrated to E3, hosts a service in the machine where the software has been installed and is being executed. This web service sends data of any kind, which are read via an I/O block. As previously discussed here, you can connect and send data from any application accessing this service.

On its first version, the driver uses WS-I Basic Profile 1.1 [5] specification, compatible with web services ASP .NET clients.

4) Installing the driver

To use this driver, you must have Microsoft .NET Framework 3.0 installed in your machine. If you do not have it, the installer will automatically download and install this program before installing the driver. Microsoft .NET Framework 3.0 Redistributable Package is also available for download at Microsoft’s website [6].

The installation process is fairly simple, as well as all other Windows’ programs. First, you must execute setup.exe file, and then advance all screens until installation is completed (Fig. 1). On the second screen, you can choose the directory to install the driver, via [Browse…] button.


Figure 1: Installing Elipse WebService driver

After the driver has been installed, it must be configured inside E3. Open the project where the driver will be used and insert a new I/O driver (Fig. 2).


Figure 2: Inserting a new I/O driver

Elipse WebService driver’s path (ElipseWS.dll) must be set at DriverLocation property (Fig. 3). If the default location had been kept, it will be at C:\Program Files\Elipse Software\Driver Web Service\ElipseWS.dll.


Figure 3: Setting the driver’s location

By default, the driver is set to host the service in the local IP address, on port 8080. To change these settings manually, you must access the driver’s settings on Web Service tab (Fig. 4).


Figure 4: Elipse WebService driver settings

New information can be inserted into fields IP Address (host name) and Listen for connections on port. [Get IP] button will fill IP Address (host name) field with the local IP address. Address field displays the web service’s address, which must be used to consume the service via other applications.

You should notice that the new settings will only be effective after the driver has been reactivated.

5) Using the driver

After the driver has been installed and properly configured, whenever it is activated in E3 Studio, or whenever an application is executed, the web service will be available and expecting communication. To check whether the web service was correctly created, access the following address on the browser: http://[host]:[port]/SendData?wsdl, replacing [host] and [port] with the information used to configure the driver. This address can be retrieved directly in the driver’s settings (Fig. 4), at Address option.

Example of address: http://localhost:8080/SendData?wsdl. If the service is working properly, an XML file similar to the one in Figure 5 will be displayed on the browser.


Figure 5: XML file generated by the web service

At this stage, the application created on Elipse E3 can receive data sent by other applications communicating with the web service: one of the options of SetParams method is called ArrayOfAnyType.

At Elipse E3, this parameter is received by an I/O block. To create the block, right-click the driver’s icon and choose the options on Insert–I/O Block menu (Fig. 6). For the next settings windows, keep quantity as 1, choose the block’s size, and click [OK].


Figure 6: Inserting an I/O Block

As seen in the previous example, to receive a 3-value array, create an I/O block with at least three elements. Each element in the received array will correspond to the element with the same index; therefore, make sure all tags’ Index property have the correct value. Figure 7 shows three elements that were received via web service, and whose indexes are 0, 1, and 2.


Figure 7: Setting I/O tags’ Index property

6) Application connected to a web service (example)

Next, we will show how a simple application (written in C# programming language and using Visual Studio 2005) can communicate with the web service. As seen before, this communication can also be established via other systems and programming languages; however, this is not the focus of this article.

Initially, you must open the Sample Project, and then locate the object Driver Web Service (sub item of Drivers and OCP). Set its correct path at DriverLocation property and check (in the driver’s configurations) whether the field IP Address displays the machine’s right name or IP number. Copy Address field and then execute the application (or simply activate the driver on E3 Studio); this causes the web service to be consumed by the application being developed.

Inside Visual Studio 2005, access Project–Add Web Reference… menu (Fig. 8). This configuration will allow the use of objects and methods provided by the web service inside the code.


Figure 8: Adding web reference to Visual Studio 2005

Type the address of the web service on the URL field and click [Go]. If the service is found, SendData (its name) and SetParams (the available method) will be displayed, as seen Figure 9. Click [Add Reference].


Figure 9:  Adding a reference to the web service being executed

It will then be possible to use the web service’s functionalities in the application. The class to be used is called SendData, and its method is called SetParams. It allows sending information to the web service to be created by the driver, in addition to other attributes such as handling Complete event (Fig. 10). For further information, please refer to the documentation on MSDN Library Online website [7].


Figure 10: Classes created by Visual Studio 2005

The Client Application works in a simple way (Fig. 11). It basically uses SendData class and SetParams method to send data to the web service and, therefore, to the E3 application being executed. Execute the sample application, type the address of the web service to be consumed on Web Service Address field, and click [Connect]. If the connection was established successfully, OK status is displayed.

The sent parameters must be filled in Parameter field and added to the list via [Add] button. To send data, click [Send] button. You can see in the status field whether data was sent successfully or not (Fig. 11).


Figure 11: Sample application communicating with the web service

Data will be received in the I/O elements of the I/O block. In this case, value Teste1 (string) will be received in 0 element, value 12345 (long) in 1 element, value 18/12/07 16:32 (date) in 2 element, and so forth. Figure 12 shows the test project’s E3 Viewer with the values sent by the client application.


Figure 12: Screen of Sample Application in E3

The client application and the Sample Project for E3 version 3.0 are available for download in this document’s attachments.

7) Final remarks

The use of web services enables the interoperability between systems and programming languages. With Elipse WebService driver, different applications will be able to access the service (send data to Elipse E3 application) via a standard that has been widely used due to its ability for allowing total integration.

Thus, although this example uses .NET Framework, the web service can be consumed by any other platform that is not .NET. Another major advantage is how easy it is to implement the client application. Matters regarding security of web services will be dealt with in the driver’s next version, when this article should be updated.

8) Web references

[1] W3C (World Wide Web Consortium) http://www.w3.org/XML/Schema
[2] OASIS (Organization for the Advancement of Structured Information Standards) http://www.oasis-open.org
[3] WS-I (Web Services Interoperability Organization) http://www.ws-i.org
[4] Microsoft. Understanding Web Services http://msdn2.microsoft.com/pt-br/webservices/aa740685.aspx
[5] Especificação WS-I Basic Profile 1.1 http://www.ws-i.org/deliverables/workinggroup.aspx?wg=basicprofile
[6] Microsoft .NET Framework 3.0 Redistributable Package (site for downloading the file) http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en
[7] MSDN Library Online http://msdn.microsoft.com/library/

Attachments:

E3Project.zip
ExampleApplication.zip
DriverWebServiceInstaller.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *