Hallo All,
We are working on REST to REST synchronous scenario. The output (xml) from mapping looks fine, but when it is transformed to JSON through REST receiver channel.
We tried using the custom XML/JSON conversion for the field "Text" in the REST receiver adapter and it is not working as expected. please check the below for more details about the requirement.
output after mapping
<?xml version="1.0" encoding="UTF-8"?>
<ns0:UIT_MT_IT_REQUEST xmlns:ns0="urn:test/po/MT-it">
<root>
<query_table>BSEC</query_table>
<DELIMITER>~</DELIMITER>
<ROWCOUNT>5</ROWCOUNT>
<ROWSKIPS>0</ROWSKIPS>
<options>
<Text>'0300'</Text>
</options>
<options>
<Text>'2022%'</Text>
</options>
<options>
<Text>IN ('320000000',</Text>
<Text>'320000002',</Text>
<Text>'320000003',</Text>
<Text>'320000004')</Text>
</options>
<root>
Output from REST Receiver adapter
{
"query_table": "BSEC",
"DELIMITER": "~",
"ROWCOUNT": 5,
"ROWSKIPS": 0,
"options": [
{
"Text": "'0300'"
},
{
"Text": "'2022%'"
},
{
"Text": [
"IN ('320000000',",
"'320000002',",
"'320000003',",
"'320000004')"
]
}
],
}
Expected output
{
"query_table": "BSEC",
"DELIMITER": "~",
"ROWCOUNT": 5,
"ROWSKIPS": 0,
"options": [
{
"Text": "'0300' "
},
{
"Text": "'2022%' "
},
{
"Text": "IN ('320000000',"
},
{
"Text": "'320000002', "
},
{
"Text": "'320000003', "
},
{
"Text": "'320000004', "
}
]
}
Rest Receiver channel configuration

Appreciate your valuable inputs and suggestions to get the expected output from the REST receiver channel.
Thanks in advance.
Best Regards
Bhargava Krishna Talasila
Request clarification before answering.
Created target XSD and adjusted the mapping to generate multiple Header elements "options".
Please check the below output xml generated from mapping and the JSON structure generated by REST adapter.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<query_table>BSEC</query_table>
<DELIMITER>~</DELIMITER>
<ROWCOUNT>5</ROWCOUNT>
<ROWSKIPS>0</ROWSKIPS>
<options>
<Text>'0300'</Text>
</options>
<options>
<Text>'2022%'</Text>
</options>
<options>
<Text>IN ('320000000',</Text>
</options>
<options>
<Text>'320000002',</Text>
</options>
<options>
<Text>'320000003',</Text>
</options>
<options>
<Text>'320000004')</Text>
</options>
</root>
JSON output from REST adapter
{
"query_table": "BSEC",
"DELIMITER": "~",
"ROWCOUNT": 5,
"ROWSKIPS": 0,
"options": [
{
"Text": "'0300'"
},
{
"Text": "'2022%'"
},
{
"Text": "IN ('320000000',"
},
{
"Text": "'320000002',"
},
{
"Text": "'320000003',"
},
{
"Text": "'320000004')"
}
]
}
Regards
Bhargava Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhargava,
You would need to map the <Text> elements into a single <options> tag. The converter is creating an array of options that each contain the individual text elements contained within the source tag (an array of elements in the case of the last tag). Create an XSLT or regular graphical message mapping to convert the XML to the following and then it should be fine:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:UIT_MT_IT_REQUEST xmlns:ns0="urn:test/po/MT-it">
<root>
<query_table>BSEC</query_table>
<DELIMITER>~</DELIMITER>
<ROWCOUNT>5</ROWCOUNT>
<ROWSKIPS>0</ROWSKIPS>
<options>
<Text>'0300'</Text>
<Text>'2022%'</Text>
<Text>IN ('320000000',</Text>
<Text>'320000002',</Text>
<Text>'320000003',</Text>
<Text>'320000004')</Text>
</options>
<root>
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan,
Thank you for your response and suggestion. The XML will be transformed to below JSON format. When posting this payload to the REST endpoint,it is giving the sysntax error.
{
"query_table": "BSEC",
"DELIMITER": "~",
"ROWCOUNT": 5,
"ROWSKIPS": 0,
"options": {
"Text": [
"'0300'",
"'2022%'",
"IN ('320000000',",
"'320000002',",
"'320000003',",
"'320000004')"
]
}
}
Regards
Bhargava Krishna
bhargavakrishna.talasila - looks like you answered at the same time I was sending a suggestion and I didn't notice the subtlety of the options array, but looks like you solved it with a minor structure variation of wrapping each text into an options tag.
Hi!
Why not to just delete "root" element from target structure?
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 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.