Implementing a Custom Field Serializer

Implement a custom field serializer in a message definition to take field data from the parsed data container and return additional data into the outgoing message, along with any specified wire formatting.

  1. In WorkSpace, configure a Java project and Java builder settings.
  2. Write custom logic to serialize field data and implement the com.sybase.jtf.serializer.api.ICustomSerializerField interface.

    The result is a custom class that passes the parsed field data in as a byte array, where the return value is the newly modified field data, which should never be null.

  3. Export the custom code as a JAR file and put the file into the CustomClasses directory under the MessageDesigns directory.
  4. If the custom code JAR file requires supporting JAR files, put the supporting JAR files in CustomClasses directory as well.
  5. Modify the Class-Path variable for the custom code JAR file and supporting JAR files.
    For example:
    $ cat manifestChange.txt 
     Class-Path: MyUtils.jar
    $ jar ufm customField.jar manifestChange.txt 
    
    Note: For more information about adding classes to the JAR file's classpath, see Adding Classes to the JAR File's Classpath at the Sun Java Tutorials documentation Web site.

    The Message Designer can now instantiate the class when the custom field JAR is loaded in the following steps where you insert the custom field code into a message definition and at runtime.

  6. To start Sybase WorkSpace, select Start > Programs > Sybase > Sybase WorkSpace > Sybase WorkSpace <version>.
  7. To start the Service Container server, select Start > Programs > Sybase > Sybase WorkSpace > SC <version> > Start SC.
  8. In the WorkSpace Navigator of the Service Development perspective, expand the project folder that contains the message definition with which you want to work, then expand the MessageDesigns and MessageDefinitions folders.
  9. Double-click the message definition file, which has a .wfim file name extension.

    The message definition file opens in the Message Definition editor.

  10. Select the Message Details tab.
  11. In the Message Definition section, expand the message definition containers and select the field in which to use the custom field code.
  12. In the Field Properties section, select the Custom Field Serializer, then click the ellipsis button to the right of that option.

    The Custom Field Serializer dialog box opens.

  13. Select the custom field JAR and the class for the field, then click OK.

    Repeat this step to add the custom field code to other fields in the message definition.

  14. Select File > Save from the main menu bar.

    The custom code is added to a message definition.

Next 

Test the message definition.

Related tasks
Testing a Message Definition
Developing a Custom Class to Transform a Message Definition Field
Implementing a Custom Field Parser
Implementing a Custom Parser Extension
Adding a Field to a Message Definition
Developing a Message Definition
Related reference
Custom Field Serializers
Custom Parser Extensions

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.