Application Integration (On-Premises) : Integration Server Built-In Services : Document Folder : pub.document:documentToBytes
pub.document:documentToBytes
WmPublic. Converts a document to an array of bytes.
Input Parameters
document
Document Document (IData object) to convert to bytes.
*If document is null, the service does not return an output or an error message.
*If document is not a document (IData), the service throws a service exception.
*If document contains no elements, the service produces a zero-length byte array.
Output Parameters
documentBytes
Object A serialized representation of the document as an array of bytes (byte[]).
Usage Notes
Use the pub.document:documentToBytes service with the pub.document:bytesToDocument service, which converts the byte array created by this service back into the original document.
The pub.document:documentToBytes service is useful when you want to write a document to a file (using the pub.file:bytesToFile service), an input stream (using the pub.io:bytesToStream service), or a cache (using the pub.cache:put service).
In order for the document-to-bytes-to-document conversion to work, the entire content of the document must be serializable. Every object in the document must be of a data type known to Integration Server, or it must support the java.io.Serializable interface. If Integration Server encounters an unknown object in the document that does not support the java.io.Serializable interface, that object's value will be lost. Integration Server will replace it with a string containing the object's class name.
Example
This example describes how to use the pub.document:documentToBytes and pub.document:bytesToDocument services to cache a document in the pipeline.
1. A document is not directly serializable, so you must first use the pub.document:documentToBytes service. Invoke the service and map the document to the document input parameter. This will add the output documentBytes to the pipeline.
2. Invoke pub.cache:put and map documentBytes to the value input parameter for that service. Set the key input parameter to a value that is meaningful to your application.
3. At another point in your application, you will need to retrieve the document you cached. You can do so by invoking the pub.cache:get service and supplying the same key input parameter as in step 2. The value output parameter that was added as output to the pipeline will contain the byte array from step 1.
4. Invoke pub.document:bytesToDocument and map the value output parameter to the documentBytes input parameter. This will add the output document to the pipeline, which will match the original document in step 1.
Copyright © 2015- 2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback