Skip to Content
Author's profile photo Former Member

Develop Java Mapping in PI 7.4 Java Only

On this occasion, I share how to create a Java mapping, PI version used is 7.4 (java only). This will help them when they need to create a complex mapping. For this example, use the DOM object, I add sample code.

I will be adding more blog posts, I hope will be helpful.


1. Download NWDS (Netweaver Developer Studio)

2. Download JDK (Java Development kit)

3. Install Java and NWDS

4. Open NWDS

5. Create new java project

18-09-2015 9-33-31.png

18-09-2015 9-36-32.png

6. Add XPI library

18-09-2015 9-38-32.png

18-09-2015 9-39-59.png

7. Create new Class (Right click on src)

  18-09-2015 9-44-07.png

18-09-2015 10-06-35.png

8. Add code (Example with Dom object)

XML outbound and inbound (Example):

<?xml version=”1.0″ encoding=”UTF-8″?>

<ns0:MT_test xmlns:ns0=””>







18-09-2015 9-59-35.png


package com.test.mapping;




import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

public class Test_JavaMapping extends AbstractTransformation { 


    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {

        String RESULT = new String();

        String inicio = “<?xml version=\”1.0\” encoding=\”UTF-8\”?>” +

        “<ns0:MT_test xmlns:ns0=\”\”>”;

        String fin = “</ns0:MT_test>”;

        String nombre = “”;

        String apellido = “”;

        String edad = “”;

        try {

            InputStream inputstream = transformationInput.getInputPayload().getInputStream(); 

            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream(); 

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();           

            DocumentBuilder builder = factory.newDocumentBuilder();


            Document doc = builder.parse(inputstream);     

            NodeList children = doc.getElementsByTagName(“row”);


            for (int i = 0; i < children.getLength(); i++) {

                        Node node = children.item(i);

                    if(node.getNodeType() == Node.ELEMENT_NODE){

                        Element eElement = (Element) node;

                        nombre = eElement.getElementsByTagName(“nombre”).item(0).getTextContent();

                        apellido = eElement.getElementsByTagName(“apellido”).item(0).getTextContent();

                        edad = eElement.getElementsByTagName(“edad”).item(0).getTextContent();


                        RESULT = RESULT + “<row>” + “<nombre>” + nombre + ” “ + apellido + “</nombre>” +

                        “<apellido>” + nombre + ” “ + apellido + “</apellido>” + “<edad>” +edad+“</edad>”+“</row>”;




            RESULT = inicio + RESULT + fin;


        } catch (Exception exception) { 

getTrace().addDebugMessage(exception.getMessage()+ RESULT); 

            throw new StreamTransformationException(exception.toString()+ RESULT); 




9. Export as jar

18-09-2015 10-20-18.png

18-09-2015 10-21-14.png

18-09-2015 10-23-21.png

10. Upload jar to PI (Enterprise Service Builder)

18-09-2015 10-32-13.png

18-09-2015 10-36-04.png

11. Save and activate

12. Use in Operation mapping

18-09-2015 10-38-51.png

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      It was very hepful , I didn't know the Developer Studio had the libraries.

      Author's profile photo Khaja Sk
      Khaja Sk

      It is very helpful. Thank you for nice step by step explanation...

      Author's profile photo Srijani Panda
      Srijani Panda

      Hi Luis,

      Just wanted to confirm, for NWDS version 6 the compatible JDK version will be JDK6 right? the higher version of Java will not be supported?

      Author's profile photo Former Member
      Former Member

      it very good blog

      I requesting you to add output also it will help us.

      Author's profile photo Aamir Khan
      Aamir Khan


      Please tell me what is the need for "Element eElement = (Element) node;" I am not getting this.




      Author's profile photo Jesus Barrera
      Jesus Barrera

      The Element interface extends the Node interface. "Node" is the kind of objects returned in the getElementsByTagName method though the objects are of type "Element". To access the content of each element we have to use the getElementsByTagName method again, which is not available on Node interface, thus we have to make the cast.

      Author's profile photo Dileep Reddy
      Dileep Reddy

      Thank you very much sir