Some real time scenario will require to have the specific namespaces as per receiver’s system however while PI does the mapping, it may not generate the payload with the exact/required namespace. In those cases we may need to remove/add/replace namespaces.

SAP has provided one JAVA Bean which could help us in case of removing/replacing namespaces. I have described how this bean can help in removing namespace(or corresponding prefix) at Remove Namespace in PI by XMLAnonymizer Bean in communication channel-Example step by step

 

In this blog we will see how this can help replacing the namespace.

 

We had one scenario where the output after mapping looks like below.

/wp-content/uploads/2014/10/pic1_559960.jpg

 

However our customer wanted the output like below.

 

/wp-content/uploads/2014/10/pic2_559994.jpg

So if you notice carefully then we needed below changes.

 

  • Remove the namespace prefix “ns0” however keep the corresponding namespace “urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2”
  • Replace the namespace prefix “ns2” with “cbc”
  • Replace the namespace prefix “ns3” with “cac”.

To do this,we have used the XML Anonymizer bean.

 

/wp-content/uploads/2014/10/pic3_559995.jpg

 

Here is the configuration procedure:

  • Add the Module in the Processing Sequence.Insert this Anonymizer module before the adapter module as shown above.

Module Name : AF_Modules/XMLAnonymizerBean

Module Type:Local Enerprise Bean

Module Key: 0

The module name ‘CallSapAdapter’ is default one that can be left as it is

 

  • Add Parameters in the Module Configuration.

Module Key: 0

Parameter Name: anonymizer.acceptNamespaces

Parameter Value:

urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2 cbc urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 cac urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2

Please note that in case you have any additional Namespaces and Prefix, you also need to maintain them in the Parameter Value along with the the changes/replacement in the same place. So if you have a namespace like soapenv:http://abc.com and you want to keep that along with above changes then the Parameter Value becomes like below.

http://abc.com soapenv urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2 cbc urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 cac urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2 ”

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Alejandro Souss

    Hi Arijit,

    Good Blog, i have a question.

    With XML Anonymizer bean i can change the prefix of the namespace of the body but

    I can not change the prefix of the namespace of the header.

    You know how to solve this?




    Regards

    (0) 
  2. Varun Goel

    Hi Arijit,

     

    I was able to replace the namespace, however new namespaces are not added in the xml file. Could you please confirm, if new namespaces can be added in the xml.

     

    Thanks

    varun

    (0) 

Leave a Reply