Skip to Content
0

SAP PI - How To Add Extra namespace in Receiver File?

Oct 13, 2016 at 09:36 PM

260

avatar image

Hi All,

This is my first question after SCN upgraded.

I need to add extra namespaces in receiver file.

Now I am getting namespace in output file like below.

<?xml version="1.0" encoding="UTF-8"?>

http://www.oracle.com/retail/integration/other/SupplierMessage">

But my client expecting below.

<?xml version="1.0"?>

http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.oracle.com/retail/integration/other/SupplierMessage" xmlns=" http://www.oracle.com/retail/integration/other/SupplierMessage">

Please help me to get expected namespaces.

Thanks In Advance,

Vishnu.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Praveen Gandepalli Oct 14, 2016 at 09:45 AM
2

Hi Manoj/Raghu/Evgeniy/Ramkumar,

XMLAnonymizerBean only to remove the namespace or namespace prefix not to add the new namespace to the XML.

According to SAP help:

You use this module to anonymize XML elements and attributes by removing namespaces or namespace prefixes from the XML document of the main payload.

The module scan each namespace and verifying that the namespace exist in the list of accepted namespaces which is specified in the module configuration, if found then adding it to the output otherwise it is not adding it to the output.

So we cannot add the new namespace using XMLAnonymizerBean.

Regards,

Praveen.



Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Praveen!

I thought so too, but wasn't absolutely sure :-)

Regards, Evgeniy.

1

Thanks Praveen..

Then XSLT mapping should be the solution.

1

Thanks Praveen Our "PI/JAVA-Expert" ;)

But still i would go with the trick to populate namespace using the StructureNode instead of the XSLT.

1

Yes, it's a nice "trick" but I wouldn't suggest using it as it's undocumented approach.

I remember the case when I used java code in my UDF based on fact that ResultList class extends standard ArrayList class.

And in next version SAP developers change it for their own custom class and my code stopped working.

Regards, Evgeniy.

1
Manoj K Oct 14, 2016 at 12:45 AM
1

XMLAnonymizerBean is capable of retaining the namespace but i dont think it will add new namespace you may try below blog :

https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/

Br,

Manoj

Share
10 |10000 characters needed characters left characters exceeded
Ramkumar Ganesh Oct 13, 2016 at 10:19 PM
0

Use AF_Modules/XMLAnonymizerBean module in the receiver channel.

Parameter name – anonymizer.acceptNamespaces

Refer the blog

https://blogs.sap.com/2012/07/10/handling-namespaces-in-pi-using-xmlanonymizerbean/

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Oct 14, 2016 at 01:16 AM
0

Hi Vishnu!

You could try with using Manoj's suggestion or use XSL transformation in Operation mapping or in channel using MessageTransformBean.

Regards, Evgeniy.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Eve,

How can we add namespace using MTB ? Do you mean write xslt place it in any OS folder and call it via MTB? or is there any way ?

Br,

Manoj

0

Hi Manoj!

Yes, you are absolutely right! That's the way and it works.

Some respective community members say that it's not good practice and I'm agree with them but in some cases it could be rather helpfull.

https://blogs.sap.com/2016/05/18/message-data-changetransformation-in-simple-pass-through-scenario/

Regards, Evgeniy.

1

Hello Eve,

But simple way could be XML anonymizer bean or XSLT in OM right?

1

Hi Raghu!

I didn't try XMLAnonymizerBean for custom namespace adding so can't be sure if it works this way.

Using XSL transformation after the main mapping in OM could be the right approach IMHO.

Regards, Evgeniy.

1