Skip to Content

Testing Adapter Module in NWDS


I have got a code for adapter module,I wanted to test it standalone using NWDS.

class XML2EdifactBean


public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException { //Some Code... }


I am getting some error while executing the adapter module ,so I want to call the function using main method.Can you provide me with a sample code for this.


Ujjwal Kumar.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on May 28, 2008 at 09:06 PM

    This would be too complex to do all necessary steps for a stand alone test.

    I recommend to split the generic adapter module stuff and the part, you really want to do something.

    For the adapter modul, which we used on Teched session:


    I did following: I introduced a helper class and passed the DOM code

    public class HelperClass {
    	String hostElementName = "host";
    	String hostName = "host";
        public static void main(String[] args) {
            try {
                InputStream in = new FileInputStream(new File("in.xml"));
                OutputStream out = new FileOutputStream(new File("out.xml"));
                new HelperClass().execute(in, out);
            } catch (Exception e) {
        public void setHostElementName(String hostElementName){
        	this.hostElementName = hostElementName;
        public void setHostName(String hostName){
        	this.hostName = hostName;
        public void execute(InputStream in, OutputStream out){
        	try  {
        		DocumentBuilderFactory factory;
            factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document = builder.parse(in);
            Element rootNode = document.getDocumentElement();
            if(rootNode != null)  {
                Element childElement =
            // Transforming the DOM object to Stream object.
            TransformerFactory tfactory = TransformerFactory.newInstance();
            Transformer transformer = tfactory.newTransformer();
            Source src = new DOMSource(document);
            Result dest = new StreamResult(out);
        	} catch(Exception e){}

    in the bean class, I used the helper class:

    	XMLPayload xmlpayload = msg.getDocument();
                InputStream in = xmlpayload.getInputStream();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                HelperClass hc = new HelperClass();
                byte[] docContent = out.toByteArray();
                if(docContent != null)  {

    Now I can test the parser in the NWDI



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 26, 2008 at 08:42 AM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.