Technical Blog Post
Abstract
Implementing TCP Socket communication using Sterling B2B Integrator
Body
| Author: Manisha Khond, IBM Cognitive Engagement, Watson Supply Chain. How to implement TCP Socket communication using Sterling B2B Integrator? Sterling Integrator offers following Services and Adapter for Transmission Control Protocol Socket communication.
How to implement outbound Socket Connection from Sterling B2B Integrator to remote Socket Server and send or receive data?
|
|
Below sample Business Process establishes connection to the remote Socket Server using Socket Connect Service. Note that you have to reference Socket Client Adapter within Socket Connect Service.Send the data to the Socket Server using Socket Write Service.In this scenario, Socket Server responds with the data after receiving a data file from Sterling B2B Integrator.The data sent by the Socket Server is then read via Socket Read Service. DataNode parameter mentions name of the node under process data where the data that is read from the Socket Read service.The connection is closed by the Socket Close Service. <process name = "mk_socket"> <rule name="Session Open"> <condition>boolean(/ProcessData/SessionToken)</condition> </rule>
<sequence name="Main"> <operation name="SocketConnectServiceType"> <participant name="SocketConnectService"/> <output message="SocketConnectServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="RemoteHost">xxx.xx.x.xx</assign> <assign to="RemotePort">5100</assign> <assign to="ResponseTimeout">30</assign> <assign to="SocketClientAdapter">SocketClientAdapter</assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
<operation name="SocketWriteServiceType"> <participant name="SocketWriteService"/> <output message="SocketWriteServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="ResponseTimeout">30</assign> <assign to="SessionToken" from="/ProcessData/SessionToken/text()"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
<operation name="SocketReadServiceType"> <participant name="SocketReadService"/> <output message="SocketReadServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="DataNode">SocketDataRead</assign> <assign to="EndOfData">35</assign> <assign to="ResponseTimeout">30</assign> <assign to="SessionToken" from="/ProcessData/SessionToken/text()"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
<operation name="SocketCloseServiceType"> <participant name="SocketCloseService"/> <output message="SocketCloseServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="SessionToken" from="/ProcessData/SessionToken/text()"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
<onFault> <sequence name="Error"> <choice name="Choice Start"> <select> <case ref="Session Open" activity="Session Open"/> </select>
<sequence name="Session Open"> <operation name="SocketCloseServiceType"> <participant name="SocketCloseService"/> <output message="SocketCloseServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="SessionToken" from="/ProcessData/SessionToken/text()"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation> </sequence> </choice> <operation name="Invoke Business Process Service"> <participant name="InvokeBusinessProcessService"/> <output message="InvokeBusinessProcessServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="INVOKE_MODE">ASYNC</assign> <assign to="WFD_NAME">mk_GenericErrorHandler</assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
</sequence> </onFault> </sequence> </process>
How to implement inbound Socket connection from remote Socket Server to Sterling B2B Integrator?
|
|
The above Socket Server Adapter invokes a business process when the connection is established with the Socket Server Adapter. |
The sample business process when executed successfully displays "This data is used for testing" at the client.
<process name="mk_socketserverdemo"> <sequence> <assign name="Assign" to="testNode">This data is used for testing</assign> <operation name="SocketWriteServiceType"> <participant name="SocketWriteService"/> <output message="SocketWriteServiceTypeInputMessage"> <assign to="." from="*"></assign> <assign to="NodeToRead" from="/ProcessData/testNode/text()"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
<operation name="SocketCloseServiceType"> <participant name="SocketCloseService"/> <output message="SocketCloseServiceTypeInputMessage"> <assign to="." from="*"></assign> </output> <input message="inmsg"> <assign to="." from="*"></assign> </input> </operation>
</sequence> </process> |
|
|
|
FAQ |
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. Note that EndOfData does not support control characters except 'CR' and 'LF'.
If you know the size of the data to be read, you can use the BytesCount. If you do not know the size of the data to be read from the Socket, use EndOfData.
Yes. Socket Client Adapter support communication using Perimeter Server.
Yes. Socket Connect Service provide the option of using SSL.
Yes. The Socket Server Adapter provide you an option of executing custom Java code OR the business process. |
|
Do you have questions or comments on the blog? Please use comments section of the blog. |
UID
ibm11120755


