on 09-09-2015 10:36 AM
Hello,
I am working on a requirement where i need to remove top node and namespaces after mapping send data to third party via SOAP.
XML Anonymizer bean is not suitable as its only usefull for playing around namespaces. Need to use XSLT or JAVA map in OM.
Output of Mapping will be:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:Target_MT xmlns:ns1="urn:creditdetails">
<cardData>
<headerData>
<Number/>
<Name/>
<transaction/>
</headerData>
</cardData>
</ns1:Target_MT>
Need to send like this:
<cardData>
<headerData>
<Number/>
<Name/>
<transaction/>
</headerData>
</cardData>
Any inputs with code sample will be appreciated.
Thanks for your help in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jan,
Just create a cardData type and use it in your message type. Just make sure to remove the namespace entry in the message type before saving it. No need to use JavaMap or XSLT.
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
nodes needs to be removed as highlighted in red. not just namespaces.
Given links are not for this requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use this java mapping i haven't compiled it but it will work
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.*;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class RemoveNamespace extends AbstractTransformation
{
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException
{
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in.getInputPayload().getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
out.append(line);
}
//removing namespace in the string we have
/*<?xml version="1.0" encoding="UTF-8"?>
<ns1:Target_MT xmlns:ns1="urn:creditdetails">
*/
line = line.substring(line.indexOf("urn:creditdetails")+20,line.length());
/* </ns1:Target_MT>
*/
line = line.substring(0,line.indexOf("ns1:Target_MT>")-2);
out.getOutputPayload().getOutputStream().write(line.getBytes("UTF-8")); //writing to output
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.