Socket Read Service

The Socket Read service reads data from a Transmission Control Protocol socket.

The following table provides an overview of the Socket Read service:

System name Socket Read Service
Graphical Process Modeler (GPM) categories All Services
Description This service reads data from a Transmission Control Protocol (TCP) socket.
Business usage A business user uses this service to retrieve data from a remote TCP server and move it into Sterling B2B Integrator. This service can also be configured to read a fixed number of bytes of data sent by a remote TCP client, process it, and send the response back.
Usage example A remote TCP client connects to the Sterling B2B Integrator socket server and transfers a fixed number of bytes. The Sterling B2B Integrator socket server reads the data using this service, processes the data, and then responds back with the processed data.
Preconfigured? No
Requires third-party files? No
Platform availability All supported Sterling B2B Integrator platforms.
Related services Related services:
  • Socket Read service
  • Socket Write service
  • Socket Close service
  • Socket Client adapter
  • Socket Server adapter
Application requirements A TCP server at the external trading partner's location is required. Information about this TCP server must be configured in the Socket Connect service or in a TCP client that connects to the Sterling B2B Integrator Socket server adapter running a business process using this service.
Initiates business processes? No
Invocation This service is invoked from a business process.
Business process context considerations A business process using the Socket Read service should not be configured to automatically resume. The Socket Read service requires an established session which will not exist if the business process is set to automatically resume.
Returned status values Returned status values:
  • 0 - Success
  • 1 - Error
Restrictions None
Persistence level System Default
Testing considerations None

Implementing the Socket Read Service

To implement the Socket Read service, complete the following tasks:
  1. Configure the Socket Read service. For information, see Configuring the Socket Read Service below.
  2. Use the Socket Read service in a business process.

Configuring the Socket Read Service

To edit the configuration of the predefined Socket Read service, you must specify field settings in the user interface service configuration:

Field Description
Name Name for the service in Sterling B2B Integrator. Required.
Description Description of the service. Required.
Select a Group Selection or creation of the group for this service. Optional.

Output from Service to Business Process

The following table contains the Graphical Process Modeler (GPM) parameters passed from the Socket Read service to the business process:

Parameter Description
SocketRead/Code Response code indicating if the write was completed successfully. Required.

Output from Business Process to Service

The following table contains the Graphical Process Modeler (GPM) parameters passed from the business process to the Socket Read service:

Parameter Description
BytesCount Indicates a positive number of bytes to be read. If the BytesCount is specified as 10, only 10 bytes of data are read from the socket. The Transfer Buffer Size can be specified in the Socket Client adapter which determines the buffer size for every read. It has a default value of 32K. If the BytesCount specified is less than the Transfer Buffer Size, only the BytesCount number of bytes are read from the socket. Optional.
EndofData Indicates the end of data pattern. This is a sequence of byte values separated by |. If the EndOfData is specified as 97|87, the data from the socket is read till the data matches 97|87. The maximum size of the pattern that can be specified as EndOfData is 255 characters. The number of bytes values specified as the pattern represents the buffer size of the read service. That is, if the pattern is 97|87, only two or less bytes of data are read from the socket at a time, and this could impact the system performance. For better performance, BytesCount should be specified, instead of EndOfData. Optional.
DataNode Name of the node under process data where the data that is read from the Socket Read service. This node is created by the Socket Read service and the data that is read from the socket is located under the node. Optional.
DocumentName Name of the document where the data that is read from the socket is placed. Optional.
ResponseTimeout Maximum number of seconds it can take for the trading partner system to respond before the service terminates. The number of seconds cannot be less than 30. Optional.
SessionToken Specifies the identifier for the session established between the Socket Client adapter and a Socket Server adapter. Required.
Encoding Encoding format used to encode all outgoing data and incoming data when adding it to process data or reading it from process data. If this encoding is not specified, no encoding will be used. Optional.
DelayWaitingOnIO Specifies the number of seconds to wait for the data transfer to complete before going into WAITING_ON_IO state. If -1 is specified, the service operates in blocking mode and waits until the data transfer has completed. Optional.

Business Process Example

Note: If the Socket Read service is used as part of a socket server business process, the Socket Connect service is not needed before using the Socket Read service.

The following example business process illustrates by using the Socket Read service:

This business process reads data from the socket into a DataNode based on what you specify for the BytesCount parameter.

<process name="SocketExample">
  <sequence>

[[Insert Connect Service here for Socket Client]]
 
     <operation name="SocketReadServiceType">
      <participant name="SocketReadService"/>
      <output message="SocketReadServiceTypeInputMessage">
        <assign to="." from="*"></assign>
 <assign to="BytesCount">12</assign>
<assign to="DataNode">testDataNode</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>

[[Insert Socket Close Service here]]
</process>

This business process reads data from the socket based on what you specify for the EndOfData parameter into a document with the name SocketDataRead.

<process name="SocketExample">
  <sequence>

[[Insert Connect Service here for Socket Client]]
 
     <operation name="SocketReadServiceType">
      <participant name="SocketReadService"/>
      <output message="SocketReadServiceTypeInputMessage">
        <assign to="SessionToken" from="/ProcessData/SocketConnectServiceResults/
                    SessionToken/text()"></assign>

        <assign to="." from="*"></assign>
 <assign to="EndOfData">117|18</assign>
<assign to="DocumentName">SocketDataRead</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>

[[Insert Socket Close Service here]]
</process>