Tuesday, March 19, 2013

Read and Write Primary Document in ​ IBM B2B Sterling Integrator using MESA

​Read​
 ​and Write Primary Document while implementing
​a ​
Custom Service in
​​
IBM B2B Sterling Integrator
​ using MESA Studio​
. ​

public WorkFlowContext processData(WorkFlowContext wfc)
            throws WorkFlowException {
        Document outputDocument;
        String codeListOutputXML = null;
        OutputStream outputStream;
        BufferedOutputStream bos;
        String svcName = wfc.getServiceName();
        XLogger log = new XLogger("SI_Auto_DeployImpl", svcName);
        wfc.harnessRegister();
        wfc.setBasicStatus(WorkFlowContext.SUCCESS);
        try {
            CodeListDeployer codeListDeployer = new CodeListDeployer();
            // Read the input from PrimaryDocument
             Document srcDoc = wfc.getPrimaryDocument();   
             codeListOutputXML = codeListDeployer.readCodeListExcel(srcDoc.getInputStream());
             //Write output to new PrimaryDocument
             outputDocument = wfc.newDocument();
             outputStream = outputDocument.getOutputStream();
             bos = new BufferedOutputStream(outputStream);
             bos.write(codeListOutputXML.getBytes());
             wfc.setAdvancedStatus("CodeList Created Successfully!!");
             bos.close();
             wfc.putPrimaryDocument(outputDocument);
        } catch (Exception e) {
            handleError(log, wfc, SI_Auto_DeployMessages.Global_Exception,
                    new Object[] { SI_Auto_DeployImpl.class.getName() }, e);
        } finally {
            wfc.unregisterThread();
        }
        return wfc;
    }


Friday, March 15, 2013

File Compress Service in IBM B2B Sterling Integrator

<operation name="Compress"> 
 <participant name="CompressionService"/>
 <output message="outputMessage">
 <assign to="." from="*"/>
 <assign to="compression_action">Compress</assign>
 <assign to="compressed_filename" from="concat('FileName__','.gz')"/>
 <assign to="compression_level">1</assign> <!-- 1 Cost Less CPU cycles -->
 <assign to="file_name">string(OriginalFileName)</assign>
<assign to="doc_to_compress">primary_doc</assign>
</output>
 <input message="inputMessage">
 <assign to="." from="*"/>
</input>
 </operation>