send pdf file in xml message
You can transform the PDF file to Base64 Binary and wrap this into a container Element with type xs:base64Binary
. For example you could use this schema definition to place your PDF file in the xml message.
<xs:complexType name="documentType">
<xs:sequence>
<xs:element minOccurs="0" name="mimetype" type="xs:string" />
<xs:element minOccurs="0" name="filename" type="xs:string" />
<xs:element name="content" type="xs:base64Binary" />
</xs:sequence>
</xs:complexType>
You can use org.apache.commons.codec.binary.Base64
for this approach if you already have commons-codec
in your project. It support use of chunked data and strings. For example:
// You can read in the PDF file with FileReader and get the bytes
// Please obey that this solution must be improved for large pdf files
Base64.encodeBase64(binaryData, true)