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.
- In WorkSpace,
configure a Java project and Java builder settings.
- 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.
- Export the custom
code as a JAR file and put the file into the
CustomClasses directory under the
MessageDesigns directory.
- If the custom code
JAR file requires supporting JAR files, put the supporting JAR files in
CustomClasses directory as well.
- 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.
- To start Sybase
WorkSpace, select
.
- To start the Service
Container server, select
.
- 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.
- Double-click the
message definition file, which has a
.wfim file name extension.
The message definition file opens in the Message Definition
editor.
- Select
the Message Details
tab.
- In the Message
Definition section, expand the message definition containers and select the
field in which to use the custom field code.
- 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.
- 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.
- Select
from the main menu bar.
The custom code is added to a message definition.
NextÂ
Test the message definition.
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.