I am trying to create an outbound excel file from XML from a web service, using B2B Callouts. I have created a workbook from xml and wrote the workbook to an OutputStream. Then the Bytes from the OutputStream was passed to the CalloutMessage. The Excel file that gets created is not in a readable format, it seems to be in ASCII. I tried writing the Workbook to a "FileOutputStream" instead of ByteArrayInputStream, the Excel file was created on the server and was readable. So my workbook contains the correct data, I am not sure what is happening when I pass the bytes from the ByteArrayInputStream to the CalloutMessage. I think that's when the message gets corrupt for some reason.
Could some one suggest me if there are a better way to pass the full workbook data to B2B CalloutMessage.
Note: Workbook is Apache POI HSSFWorkbook.
ByteArrayOutputStream out = new ByteArrayOutputStream();
cmOut = new CalloutMessage(out.toByteArray());
Any ideas and suggestions are greatly appreciated,
It is expected. From back-end you are passing the XML and using callout within B2B, you are changing it's content-type itself (converting it into excel). You may like to try below steps -
1. Pass XML to B2B from back-end through a JMS queue (use JMS internal listening channel in B2B to receive XML from JMS queue)
2. Set below custom JMS header from back-end while enquing the XML into JMS queue -
3. Turn off the validation in the agreement and redeploy it.
4. Run a test again