Configure Java serialization for the SCA default binding
We can convert objects to a wire format, or serialize the objects, before transmitting them. We can serialize objects for applications that use the Service Component Architecture (SCA) default binding.
When using the default binding, objects are serialized to one of several wire formats before being sent. By default, objects are serialized to XML and sent as text over the wire. However, XML serialization occurs only with classes that are JAXB serializable. These classes require a default, no-argument constructor as well as getter and setter methods for each field.
To use non-JAXB serializable objects, specify a different wire format in the composite definition file. Default binding element wireFormat.javaObject as a child element.
Figure 1. For non-JAXB serializable objects, use the wire format javaObject for the SCA default binding
When wireFormat.javaObject is used, objects use Java serialization instead of XML and travel as a stream of bytes over the wire. This enables you to use, for example, non-JAXB serializable Enterprise JavaBeans with the default binding.
- Open an editor on the composite definition file for your SCA application.
- Add Java serialization in the default binding of the composite definition file.
- Add the product SCA namespace to the composite:
<composite xmlns:sca="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06">
- For each service or reference <binding.sca> element, add a wireFormat.javaObject child element using that namespace:
<sca:wireFormat.javaObject/>
- Save the changes to the composite definition file.
Results
You have configured Java serialization over the default bindings for the SCA service or reference.
Use the incorrect wire format might cause a runtime exception in the application.
Example
The following composite definition file configures Java serialization in the SCA default binding:
<?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://scajavaserialize" xmlns:sca="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06" name="sca-java-serialize-backend"> <component name="SCAJavaSerializationBackendComponent"> <implementation.java class="test.bindings.sca.SerializeBackendImpl"/> <service name="SerializeBackendService"> <interface.java interface="test.bindings.sca.SerializeBackendService" callbackInterface="test.bindings.sca.SerializeCallback"> <binding.sca> <sca:wireFormat.javaObject/> </binding.sca> <callback> <binding.sca> <sca:wireFormat.javaObject/> </binding.sca> </callback> </service> </component> </composite>
What to do next
Deploy the SCA component in an application.
Related concepts
SCA composites
Related tasks
Configure the SCA default binding Specify bindings in an SCA environment