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.
However our customer wanted the output like below.
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.
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 ''