This demo shows how to write a custom serializer and deserializer for the document/literal style.
For example, if you have written a Java service returning a java.lang.Long object, that object can represent either a numerical value or a <null>. There are some languages (such as C#) which may have a problem deserializing a <null> value into long data type.
For purposes of this demo, we assume that we have this same problem in a Java service. The Long object will be represented on the client side as a structure (which can be <null>) with the member: public long value.
To create the demo, the following steps were performed:
Firstly, an XML Schema structure was created for the LongObject object (src/LongObject.xsd).
Secondly, the custom serializer and deserializer were created for the LongObject object (src/demo/advanced/longobject/*.java).
Finally, using the deployment descriptor (src/serialization_package.xml), the LongObject serialization package is created and is deployed only on the server.
The code for the service doesn't need to be changed in any way. Instead, the generated WSDL for the service endpoint will present java.lang.Long as a LongObject. Thus client sees the structure and works with it appropriately.
![]() | Note |
---|---|
This demo works for the document/literal style only. For RPC/encoded style serialization view the MessageFormat demo. |
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/longobject/server/ | Server source code |
src/demo/advanced/longobject/client/ | Client source code |
You can run the demo using the "run.sh" (for UNIX) or "run.bat" (for Windows) scripts. Running the script without arguments prints out a help message on screen.
This demo can only be run using Persistent Deployment.
To run using Persistent Deployment:
Be sure that you've started the SESJ.
Compile the custom serializers package.
Windows: run.bat make_serializer_package Linux: ./run.sh make_serializer_package
Deploy the custom serializers package.
Windows: run.bat deploy_serializer_package Linux: ./run.sh deploy_serializer_package
Compile LongObjectService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy LongObjectService on the SESJ.
Windows: run.bat deploy_service Linux: ./run.sh deploy_service
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run LongObjectClient (it calls LongObjectService).
Windows: run.bat run_client Linux: ./run.sh run_client
Undeploy LongObjectService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service
Undeploy the custom serializers package.
Windows: run.bat undeploy_serializer_package Linux: ./run.sh undeploy_serializer_package