cancel
Showing results for 
Search instead for 
Did you mean: 

Removal of some Tags from the source structure

Former Member
0 Kudos

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>
<AccessLicenseNumber>XXXXXXXXXXX</AccessLicenseNumber>
<UserId>XXXXXXXX</UserId>
<Password>XXXXXXXXl</Password>

</AccessRequest>

-<ShipmentConfirmRequest>
-----------
----------
</ShipmentConfirmRequest>

Output structure as
<?xml version="1.0"?>

<AccessRequest>

    <AccessLicenseNumber>XXXXXXXXX</AccessLicenseNumber>

    <UserId>XXXXXXXX</UserId>

    <Password>XXXXXXXXX</Password>

  </AccessRequest>

  <?xml version="1.0"?>

- <ShipmentConfirmRequest>

-----------

----------

</ShipmentConfirmRequest>


Accepted Solutions (0)

Answers (2)

Answers (2)

GauravKant
Contributor
0 Kudos

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;
  
}

Former Member
0 Kudos

Hi Chennum,

removing namespaces is covered in this blog:

http://scn.sap.com/community/pi-and-soa-middleware/blog/2014/10/02/remove-namespace-by-xmlanonymizer...

Regards,

Thomas

Former Member
0 Kudos

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"?>

Ryan-Crosby
Active Contributor
0 Kudos

Hi Chennum,

If the XML Anonymizer is not working for you then you could try duplicating the message type to the target with the following minor adjustment and then add a 1:1 mapping.  The result is that the target message will not have the namespace declaration.

Regards,

Ryan Crosby