cancel
Showing results for 
Search instead for 
Did you mean: 

Remove ns0: from Output

Former Member
0 Kudos


I am using SOAP receiver CC.

PI Output are asbelow:

-

After removing the ns0: the messages are processing successfully

is it possible to send a message by PI with out ns0: ? after mapping the output are adding ns0: automatically . is there any standard module to handle the same issue. I used XMLAnonymizerBean but its not working. Please suggest

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member184789
Active Contributor
0 Kudos

Hi,

Apart from these, you can also have a Java mapping added below your message mapping. The code could be like:

package p123;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.io.Reader;

import java.util.Map;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.DynamicConfiguration;

import com.sap.aii.mapping.api.DynamicConfigurationKey;

import com.sap.aii.mapping.api.InputHeader;

import com.sap.aii.mapping.api.StreamTransformationConstants;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class LeadTec extends AbstractTransformation{

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

     {

         String oldFilename = "";

         String newFilename = "";

      try

      {

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

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

           byte[] b = new byte[inputstream.available()];

          inputstream.read(b);

          String inData = convertStreamToString(transformationInput.getInputPayload().getInputStream());

            InputHeader messageHeader = transformationInput.getInputHeader();

          Leac le = new Leac();

          String St2 = le.transform(inData);

          transformationOutput.getOutputPayload().getOutputStream().write(St2.getBytes("UTF-8"));

      }

      catch (Exception exception)

      {

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

       throw new StreamTransformationException(exception.toString());

      }

    

     }

        public String transform(String input) {

       

        return input.replaceAll("ns0:", "");

    }

        private String convertStreamToString(InputStream in) {

            StringBuffer sb = new StringBuffer();

            try {

                InputStreamReader isr = new InputStreamReader(in);

                Reader reader = new BufferedReader(isr);

                int ch;

                while ((ch = in.read()) > -1) {

                    sb.append((char) ch);

                }

                reader.close();

            } catch (Exception exception) {

            }

            return sb.toString();

        }

       

        public static void main(String[] args)

             {

// Local Testing

        try {

            InputStream in = new FileInputStream(new File("C:/Users/IBM_ADMIN/Desktop/BakarNew.txt"));

            OutputStream out = new FileOutputStream(new File("C:/Users/IBM_ADMIN/Desktop/test1234.txt"));

            Leac  myMapping = new Leac();

            String input = myMapping.convertStreamToString(in);

            String new_filename = myMapping.transform(input);

            out.write(new_filename.getBytes("UTF-8"));                            

         

          } catch (Exception e) {

            e.printStackTrace();

          }

            }

       

       

}

Harish
Active Contributor
0 Kudos

Hi Tanmay,

Please check the below blogs

regards,

Harish

former_member184720
Active Contributor
0 Kudos

Deleted my reply as it's already shared by Amit..

Message was edited by: Hareesh Gampa

Former Member
0 Kudos

Hello,

There are quite a few threads on SDN pertaining to ur problem? Did u check that?

http://www.saptechnical.com/Tutorials/XI/XMLPayload/Index.htm

Thanks

Amit Srivastava