Runtime components : Core components : Formatters : Tasks : Handling binary message
  
Handling binary message
There are a lot of applications which are written in Cobol or C or C++ or Assembler. Sometimes, it is necessary to communicate with these applications in Java application. Legacy applications send and receive messages in binary mode, so it is difficult for the legacy applications to understand XML or WebService or SOAP messages, and it is also difficult to construct a binary message that the legacy application can understand. As a result, formatters are useful in converting data.
The following section introduces the terms:
Binary Message:
Binary Message is an array of bytes. You can regard it as an array of characters. Many legacy applications can only consume and produce Binary Message rather than XML or SOAP messages.
For example, following is an example of Binary Message: 06C785969987850400000012.
It is an array of bytes. The 06 is a length indicator indicating that the following 6 bytes C78596998785 should be recognized as a field. The legacy application parses it into a String, and the encoding is cp937. C78596998785 is the binary representation of the String "George". Byte 04 is also a length indicator, indicating that the following 4 bytes 00000012 should be recognized as a field. In this case, the legacy application parses it into an integer, and 00000012 is the binary representation of integer "18".
Data Object:
Data Object is a structured data in Java. There are many kinds of Data Objects, such as BTTContext, DataElement, Java Bean Service, and HashMap that holds keys and values.
Format:
Format is to translate a Data Object into a Binary Message.
Unformat:
Unformat is to translate a Binary Message into a Data Object.
Formatter:
Formatter component is used to handle legacy binary messages. It can format a data object into binary message, and unformat a binary message into data object. To do so, you only need several lines of Java code and a rule defined in an XML file, for example, FormatElement. There are many predefined FormatElements that can be used directly. You can add your own FormatElements.
Formatter translates data object through a DataAdapter interface. The toolkit provides JavaDataAdapter (adapter for java data object) and BTTContextDataAdapter (UDTT Context data object). You can extend your own adapter to support other types data objects, for example SDODataAdapter (adapter for Service Data Object), HashMapDataAdapter (adapter for HashMap), and so on.
See
Formatting a JavaBean into binary message
Handling different kinds of Data Object
Adding your own FormatElement
Using your own ElementProcessor
Integrating with other UDTT components
Go up to
Tasks