on ‎2021 Jun 16 9:05 AM
Hello guys,
I'm trying to solve quite specific problem. I went through a lot of posts and KB's but I didn't found any helping result.
I have 1 node called "DATA" which must be handled in 2 different ways - in 1 node as single value, in other as array.
In attachment there is XML example, important part is that I made XML with 2 namespaces
and REST Result example how it should look like.
http://muh.com/Akeneo/SimpleTypes and http://muh.com/Akeneo/MultiTypes
XML example of the node's
<ns1:data xmlns:ns1 = "http://muh.com/Akeneo/SimpleTypes">C 2222</ns1:data> <!---- no table
<ns2:data xmlns:ns2 = "http://muh.com/Akeneo/MultiTypes">A</ns2:data> <!-- must be table
Definition of the REST Adapter

Result - which I want to achieve
{
"node1": {"data": "C 2222"},
"node2": {"data": ["A"]}
}
Result which I've got - ALL DATA nodes are mapped as array in both namespaces
{
"node1": {"data": ["C 2222"]},
"node2": {"data": ["A"]}
}
Question is if I understand namespaces in the REST channel correctly.
Do you have any idea if this task can be somehow solved on PI?
We have XI ADAPTER FRAMEWORK 7.50 - SP 20
Thank you very much for your help
Petr Hodbod
Request clarification before answering.
Hi Petr,
As far as i know, there is no way that we can have the same element i.e "data" in your case with one as an array and another one as an object with the rest adapter configuration. With the config you have maintained if you enable "NameSpace mapping" with no namespace defined (Jut enable that option don't provide any namespace/json prefix in that ) you will get output like below where the prefix will be part of the element name in the JSON.
{
"node1": {"ns1.data": "C 2222"},
"node2": {"ns2.data": ["A"]}
}Thanks,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Manoj,
Thanks a lot for that.
Petr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manoj,
I'd like to ask you 1 more question, regarding this solution. Do you think can we use some ModuleBean to remove prefixes after that conversion is done? I was thinking about XMLAnonymizer, but it brings error that these namespaces doesnot exists, which is probably correct.
Thanks a lot
Petr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Petr ,
I don't think you can use Anonymizer bean , note in receiver channel module execution takes first then the adpater config . But in your case the prefix is added during adapter config i.e after module execution.
Either you have to do completely write custom module to do XML to desired json .
Thanks,
Manoj
Hi Manoj
thanks a lot for your answer. I've thought that this is not possible.
Petr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.