To generate the XML, you could use this library to generate it quite easily:
https://github.com/iwyg/xmlbuilder
For the encryption; I could be wrong but it looks like (from this page) you can generate the encoded results in java one time and just paste in the results to your PHP variables.