cancel
Showing results for 
Search instead for 
Did you mean: 

Remove XML Prefix in SOAP Sender Adapter

Former Member
0 Kudos

Hi

I am using a SOAP sender adapter and testing it from SOAP UI. The format that is generated from the web service is

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

<soapenv:Body>

<sap:SALES_ORDER xmlns:sap="http://XYZ.org/">

<sap:HEADER>

<sap:BATCH_ID>XYZ</sap:BATCH_ID>

<sap:CREATE_DT>XYZ</sap:CREATE_DT>

This format when processed in SOAP UI gave error which its not giving for other files. Clearly I need to remove this sap: tag, I can't use XML anonymizer as it is SOAP adapter and I can't select do not use soap env...Could anyone provide me Java/xslt code for the same..I tried all the codes on sdn but none of them worked.

Regards,

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Another thing is that when I replaced all of the sap: tags from the file using CTRL+H the file got processed successfully..therefore all the tags sap: which are generated from the Web Service in the whole file should be removed.

former_member192851
Active Participant
0 Kudos

SImple Java mapping, that should help


import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.*;
import org.w3c.dom.*;

public class DeleteCDATA_DOM_mapping extends  AbstractTransformation  {
	
	public void traceXML(Node n,int i)
	{   AbstractTrace trace = getTrace();
		trace.addInfo(i+"$"+n.getNodeName()); 
		trace.addInfo(i+"$"+n.getNodeValue());
		trace.addInfo(i+"$"+n.getNodeType()+"");
	};
	
	
	public void traceNL(NodeList nl)
		{  	for (int i=0 ; i<nl.getLength();i++)
			{
				traceXML(nl.item(i),i);
			}	
		};
	
	
	
	public void transform(TransformationInput in, TransformationOutput out) 
			throws StreamTransformationException {
				AbstractTrace trace = getTrace();

				


					try {
					
						InputStream is0=in.getInputPayload().getInputStream();

						StringBuffer out1 = new StringBuffer();
						byte[] b = new byte[4096];
						for (int n; (n = is0.read(b)) != -1;) {
							out1.append(new String(b, 0, n,"UTF-8"));
						}
						String sss=out1.toString();
			
						sss=sss.replaceAll("<sap:", "<");
						sss=sss.replaceAll("</sap:", "<");
			
						OutputStream os = out.getOutputPayload().getOutputStream();
						os.write(sss.getBytes("UTF-8"));
			
					} catch (Exception e) {
						throw new StreamTransformationException(
							"Exception in DeleteCDATA_DOM_mapping JAVA mapping 😞 "
								+ e.getMessage());
		}
	}
}