SENTINEL White Paper


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

SENTINEL White Paper

  1. 1. PRODUCT WHITE PAPER SENTINEL ™ Setting up SENTINEL Data Exchange to Communicate with the AS/400 TEKLYNX International October 8, 2007
  2. 2. Introduction In today’s information-rich business environment, data in different formats is being generated around the clock by multiple systems. The task of efficiently processing a large amount of data can sometimes present a challenge for those businesses needing to input their data into an existing AS/400 system. Teklynx’ SENTINEL S/5 server-side printing software provides an automated solution that allows you to retrieve data or manipulate data from one or multiple systems and input that data directly into an AS/400 database. SENTINEL’s Data Exchange edition provides additional data input and processing options that allow you to easily direct the movement of data through the enterprise. Specifically, its Web Services data processing plug-in allows for flexibility in data handling and provides an automated solution for processing and printing data being sent from multiple platforms or systems. This white paper explains how to utilize the Web Services plug-in within SENTINEL Data Exchange to communicate with the AS/400. Please Note: You will need to have web services installed and enabled on the SENTINEL server or another server that can be accessed by the SENTINEL server. You may use Microsoft’s web services or even Mono, the open-source web services server from It is recommended, for simplicity and security, to have web services installed on the SENTINEL server and to lock down the server to only allow for local connections, i.e. SENTINEL, to utilize the services. Please ask your system administrator for more information. The following series of steps assumes that SENTINEL and web services are installed on a single server. I. Create the Web Service First, you will need to create the web service that will provide the communication into the AS/400 DB2 database. This script will be placed in an accessible directory within the web services instance. In this example, the document resides in the “as400” directory and the file is named “as400db2.asmx.” The following figure provides a screenshot view of the contents of the as400db2.asmx file. This file provides the framework for you to communicate with the database. Setting Up SENTINEL Data Exchange to Communicate with the AS/400 2
  3. 3. <%@ WebService Language="C#" Debug="true" Class="SENTINEL"%> using System; using System.Web.Services; using System.Text; using System.IO; using System.Data.Odbc; public class SENTINEL { [WebMethod()] public string echo(string input1, string input2) { OdbcConnection DbConnection = new OdbcConnection("dsn=machine;uid=username;pwd=password"); DbConnection.Open(); OdbcCommand DbCommand = DbConnection.CreateCommand(); string sqlstring = "INSERT INTO db2test (col1, col2) VALUES ('" + input1 + "','" + input2 + "')"; DbCommand.CommandText = sqlstring; OdbcDataReader DbReader = DbCommand.ExecuteReader(); DbReader.Close(); DbCommand.Dispose(); DbConnection.Close(); return (input1); } Figure 1 – Contents of the as400db2.asmx file Setting Up the Connection The next step is to configure the file to suit your particular installation. The following line contains the information needed for the web service to connect to the AS/400 database: OdbcConnection DbConnection = new OdbcConnection("dsn=machine;uid=username;pwd=password"); Note: There is a space after the word “new” as this should all be on one line. Setting Up SENTINEL Data Exchange to Communicate with the AS/400 3
  4. 4. To connect to the server, you must enter your server name, user name, and password. For example, if your server is named MCP, your user name is Flynn, and your password is reindeer-flotilla, the line would read: OdbcConnection DbConnection = new OdbcConnection("dsn=MCP;uid=Flynn;pwd=reindeer-flotilla"); Number of Variables Needed This line dictates the number of variables used: public string echo(string input1, string input2) If you need to add more variables, continue adding strings and names inside the parentheses. For example, if you needed to add one more variable, the line becomes: public string echo(string input1, string input2, string input3) Putting Information in the Database This line is the SQL query that inserts information into the database: string sqlstring = "INSERT INTO db2test (col1, col2) VALUES ('" + input1 + "','" + input2 + "')"; In this example, the table name is db2test, and we are populating two columns, col1 and col2. Adding another variable requires manipulating the SQL statement while maintaining the special delimiters needed by the script. In this case, adding a variable will require inserting another column name and "','" + input3 + after the final plus sign. string sqlstring = "INSERT INTO db2test (col1, col2, col3) VALUES ('" + input1 + "','" + input2 + "','" + input3 + "')"; Setting Up SENTINEL Data Exchange to Communicate with the AS/400 4
  5. 5. Testing The script can be tested by opening a web browser and going to http://localhost:8088/as400/as400db2.asmx. Note: In this URL, the “8088” represents the port on which the web service listens. Your server may be listening on a different port. Click on the as400db2 method in the left navigation and then test form in the main pane. The form will ask you to manually populate the variables. When you hit submit, the page will change and will display the following: <?xml version="1.0" encoding="utf-8"?> <string xmlns="">input1</string> The input1 displayed will be the content of the variable input1. II. Configure the Mapper Here is an example of a map with a new zone created. Figure 2 – New zone created in the Mapper Setting Up SENTINEL Data Exchange to Communicate with the AS/400 5
  6. 6. Double clicking on Web Method, as found in the left navigation, brings up a screen that will allow you to add a web service by clicking the Add button. Figure 3 –Add a call to the web service You are presented with a box that allows you to enter the URL of a web service. In this example, enter http://localhost:8088/as400/as400db2.asmx and then click the green arrow. Figure 4 –Enter web service URL Setting Up SENTINEL Data Exchange to Communicate with the AS/400 6
  7. 7. You can now give proper aliases to the web service and its variables. Hint: Mapping variables will be much easier if the variable aliases match the fields on your label or document. By selecting each alias box and typing, you can assign aliases to the web service and its variables. Figure 5 –Assign aliases Clicking Close takes you back to the previous window. You can now select the configured service by clicking the box next to the name and then clicking OK. Figure 6 –Web service available in Call Selection list Setting Up SENTINEL Data Exchange to Communicate with the AS/400 7
  8. 8. The web service alias is now displayed in the left pane next to “Web Method.” Figure 7 –Web service alias displayed in the Mapper Next, you can assign the zone to one of the variables of the web service in the same way you would assign a zone to a label field. Right-clicking on the zone and selecting Link to a target variable shows the web service variables. Figure 8 –Web service variables available for selection Continue configuring your map as you normally would. Setting Up SENTINEL Data Exchange to Communicate with the AS/400 8
  9. 9. III. Configure the Sentinel In your sentinel, enable the web services processing plug-in by clicking the box next to Web Service Client and then clicking Settings. Figure 9 –Select the Web Service Client plug-in The next screen will allow you to select the web service entry created while working in the Mapper. You can also add or delete web services here in the same way as described in Section II. Figure 10 –Select your web service entry Click the box to enable the web service and click OK. You can now configure the rest of the sentinel as you normally would. Setting Up SENTINEL Data Exchange to Communicate with the AS/400 9
  10. 10. Conclusion This is the basic method for inputting data directly into an AS/400 database in conjunction with the automation provided by SENTINEL Data Exchange. The Web Services plug-in, like all of the processing plug-ins, can be used individually or in conjunction with the other plug-ins. Additionally, this plug-in enables more creativity in data handling and processing. Consider expanding your current web service to allow for retrieving data or manipulating data from one or multiple systems. For More Information For more information on SENTINEL and its Data Exchange functionality, visit the Teklynx web site at Copyright 2007 Braton Groupe sarl. All rights reserved. This white paper is for informational purposes only. Product specifications are likely to change. TEKLYNX and SENTINEL are trademarks or registered trademarks of Braton Groupe sarl or its affiliated companies. Other product or company names mentioned herein may be the trademarks of their respective owners. Setting Up SENTINEL Data Exchange to Communicate with the AS/400 10