3

I want to integrate smooks into the mule ide.We are trying to shift from webmethods to mule. We have a Edi transformation available in smmoks which we want to make use of.I found Smooks-for-Mule.jar that could be integrated to the mule. I searched the net but couldn't find any examples to help me out.Atleast can you please guide me to what to look for,so i can go ahead,i couldn't find any one experienced in my project to help this out.

This question seems small,but can u guys put an effort on this. First question,by the way..:-}

1 Answers1

2

You could use something like the following (slightly modified for your usecase):

public abstract class EdiSmooksTransformer extends AbstractTransformer 
{
    private Smooks smooks; 

    public EdiSmooksTransformer() throws IOException, SAXException 
    {
        smooks = new Smooks();
        smooks.setReaderConfig(new EDIReaderConfigurator("MY_EDI_CONFIG_FILE_PATH_HERE"));
    }

    @Override
    protected Object doTransform(Object src, String enc) throws TransformerException 
    {
        StringResult stringResult = new StringResult();
        smooks.filterSource(new StreamSource((BufferedReader) src), stringResult);
        return stringResult.getResult();
    }

}
Víctor Romero
  • 5,107
  • 2
  • 22
  • 32