Integration using TCP/IP sockets

IBM Knowledge Center Topic

Learn how to use TCP/IP nodes for integration with external applications by using TCP/IP sockets.

Import Source Code

Click Import to load the TCPIPServer and TCPIPClient applications, and the DataLibrary shared library into your workspace. These resources are then listed in the Application Development view

Within the TCPIPServer application, a message flow titled TCPIPProvider.msgflow receives the XML message through an HTTPInput node. The message is parsed and passed to the TCPIPServerOutput node to send the data to the client connected on port 7778. The TCPIPServerOutput node is configured by using the configurable service TCPIPTutorialServerCF. To avoid deployment errors, the configurable service must be created on the target deployment integration node before the application is deployed. Trace nodes are used in this tutorial to trace the data flow into the common file while the data travels through the message flow.

The TCPIPClient application contains a message flow called TCPIPReceiver.msgflow, which uses the TCPIPClientInput node to receive the data from the server. The TCPIPClientInput node is configured with the configurable service TCPIPTutorialClientCF that specifies the host, the port, and the minimum number of client connections that are automatically opened. This message flow also contains a Mapping node that uses nested maps to transform the message data into a different format. Finally, the message is written to a file through the FileOutput node.

The shared library DataLibrary contains a message model for the input and output message formats SaleReport.xsd, SaleMessage.xsd, as well as a test message that will be used to initiate the tutorial flow TestSaleMessage.xml. It also contains a batch file configure_tcpip.bat that contains commands are run in the IBM Integration Console to create the two configurable services for this tutorial.

Find out more

Exploring the flows and creating configurable services

Open the message flow TCPIPProvider.msgflow in the application TCPIPServer. The annotations attached to the nodes provide details of the node configuration. To view details about each node, click on the Properties view and then select a node on the editor canvas. The Connection details property of TCPIPServerOutput node points to a configurable service TCPIPTutorialServerCF.

If you open the message flow TCPIPReceiver.msgflow in the application TCPIPClient, you can also view more information about particular node configuration by viewing the annotations shown on the canvas. The Connection details' property of the TCPIPClientInput node points to a configurable service TCPIPTutorialClientCF. The Records and Elements tab allows you to configure the record detection.

To successfully prepare the tutorial you must define two configurable services in the integration node to create TCPIP service definitions and also deploy the TCPIPClient Application to an integration server. The steps needed are as follows: In the IBM Integration Toolkit Application Development view locate the file configure_tcpip.bat file. It is in the DataLibrary, other resources folder . Right click the file > select Open With > Text Editor. Change the value of TESTNODE_user_id to be the name of the integration node that you are using and save the file. Then run the configure_tcpip.bat file from an IBM Integration Console. Right click > Properties on the file name will show its location in the file system. Next select the TCPIPClient Application in the Application Development view of the Toolkit and right click on it, select deploy and select the default Integration server. Select Finish to confirm this.

To successfully deploy your application to the integration server, you must create two required configurable services. To create the configurable service on the target integration node TESTNODE_user_id used by the Flow Exerciser, run the provided configure_tcpip.bat file in the IBM Integration Console.

Tip 1:If port 7778 cannot be used, you might need to adjust the ports set in the configurable services commands for your system.

Tip 2:If your operating system is not Windows, you must update the file system paths used by the Trace and FileOutput nodes. Directory property of the FileOutput node specifies the directory where the output file is written to. File path property of the Trace nodes specify the full path to the trace file. By default all the files are written to 'C:\temp'.

Next, you will deploy and run the tutorial to see how the data travels from the TCPIPServer node to the TCPIPClient node and then to the file on the file system. Click Run to see those steps.

Follow these steps to complete the tutorial

Deploy and run the tutorial message flows:

  1. Open the TCPIPProvider.msgflow message flow from the application TCPIPServer by double-clicking on it. Click the Flow Exerciser icon to start recording the message path through the flow.
  2. Click the Send Message icon to select a message to send to the flow.
  3. Add a new input message to the tree on the left and check the Import from file option. Then select the file /DataLibrary/TestSaleMessage.xml from the workspace. Click the Send button to invoke the flow.
  4. After the request message is processed, the message path is automatically highlighted on the message flow.

Verify the flow execution:

  1. Click on any connection to see the data that passed through that connection.
  2. You can also open a trace file C:\temp\TCPIP_TRACE.txt specified by the Trace nodes to see how the message travels through the message flows.
  3. The same output directory contains the output file C:\temp\TCPClientTutorialOutput.txt created by the file output node. The file contains the transformed message SalesReport.
  4. To stop recording the message path through the flow, click the Return flow to edit mode icon Return flow to edit mode.
  5. You can click the Clean up action to remove the tutorial source code from the workspace. You need to manually go to the target integration servers and delete the deployed applications by using the Delete context menu.