on 09-07-2016 12:44 PM
Hi All,
My requirement is Proxy to Soap synchronous call, when ever the target structure is push to third party they won't accept with namespaces(strike out content below), need to transform the source to target structure as shown below.
please suggest ways to map from source to target 🙂
Input structure
<?xml version="1.0" encoding="utf-8" ?>
<n0:MT_ABC_Request xmlns:n0="http://abcd.com/INFXXXXXXX/AcctValid" xmlns:prx="urn:sap.com:proxy:XXX:/1SAI/TASF6A5F67EC47CBA056A4E:740">
</AccessRequest>
<AccessRequest>
<AccessLicenseNumber>XXXXXXXXX</AccessLicenseNumber>
<UserId>XXXXXXXX</UserId>
<Password>XXXXXXXXX</Password>
</AccessRequest>
<?xml version="1.0"?>
Hi Chennum,
Try XSLT mapping and use ' omit-xml-declaration="yes" 'code. It will omit the declaration.
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
or you can try it by using java mapping also.
Code:
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Text;
public String convertXMLFileToString(String fileName)
{
try{
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
InputStream inputStream = new FileInputStream(new File(fileName));
org.w3c.dom.Document doc = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
StringWriter stw = new StringWriter();
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.setOutputProperty("omit-xml-declaration", "yes");
serializer.transform(new DOMSource(doc), new StreamResult(stw));
return stw.toString();
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chennum,
removing namespaces is covered in this blog:
Regards,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
Thanks for your quick reply ,this blog i already tried .
Since this is proxy we are having other tags generated by proxy which we need to remove (" encoding="utf-8" ) and also add the XML version tag at the end of access request tag
? <?xml version="1.0"?>
<AccessRequest>
<AccessLicenseNumber>XXXXXXXXX</AccessLicenseNumber>
<UserId>XXXXXXXX</UserId>
<Password>XXXXXXXXX</Password>
</AccessRequest>
<?xml version="1.0"?>
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
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.