on 2015 Jun 24 7:05 AM
Hi all,
I wonder if it is possible to convert following json response into xml within standard REST receiver adapter?
{
"query": {
"resultCode": 0,
"columns": ["id", "customer_no", "language"],
"table": [
["331106", "3001158", "DE"],
["322205", "11407729", "DE"],
["313331", "346559", "DE"]
]
}
}
For example in something like this:
<table>
<column>
<id></id>
<customer_no></customer_no>
<language></language>
</column>
<column>
<id></id>
<customer_no></customer_no>
<language></language>
</column>
</table>
I configured my rest adapter as following:
How must the message type look like so that I could use the response for a proper mapping?
Thanks for any idea.
Stefan
Request clarification before answering.
Hi Stefan,
yes, its possible to convert that json to xml when your PI system is grater than 7.4SP10 patch level 5
below is the structure you can create.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:RestResponseData xmlns:ns0="http://chsefel.com/TRAINING_PI/REST">
<query>
<columns>
<node1>id</node1> (0..unbounded)
</columns>
<resultCode>0</resultCode>
<table>
<record>(0..unbounded)
<node2>331106</element>(0..unbounded)
</record>
</table>
</query>
</ns0:MT_RES>
and your configuration seems good for response side which is below to your screenshot.
and request side you have kept data formate is JSON, here can confirm one thing ,
are you sending json data to receiver system. if yes i think you need to do small correction in request side like. check for convert xml Payload to json also
Thanks,
Maheswarareddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
>>But it still does not convert it into wished structure.....
this mean you are getting mapping exception due to structure mismatch, if so you can create structure as per that response structure.
can you please tell me which method(POST,PUT,GET) you are using?
if you are using GET method..i will suggest you follow way to run interface
1. create an receiver communication channel
2.while you create communication channel you need to give url, in that url in case you need to keep variables, keep as hardcoded like below
url : https://xxxxxxxxxxxxxx/waste-transfers/43b3215e-4f85-41fd-9204-a4c100b14c02
actually url we suppose to keep in real time like https://xxxxxxxxxxxxxx/waste-transfers/{ID}
that id we need to pass dynamically.
so i suggest try to hard code varables first in url
3.create an dummy ico, i mean with out sender and receiver structure.
4.and run that interface
once you run that interface you must be see successfully msg in xml formate(because that receiver cc will convert json to xml)
5.as per that response converted xml data , you create structure.
if you still have doubts, please let me know full requirement and what error you are getting.
regards,
Maheswarareddy
Hi Stefan,
in mean time i also checked that how Rest adapter is converting structure.
yes REST adapter not converting as we expecting when specially nested structure case,
and its not an matter , you will get data in flat structure, accordingly you can follow the structure.
like if field comes multiple times mention as 0..unbounded.
however your screenshot seems wsdl structure .i dont think that data you are getting from PI server and must have tested in soap ui.
in case you really get that data with that structure, i believe you can not handle by graphical mapping...need to go for either xslt or java mapping because that structure has extra namespaces.
Thanks & Regards,
Maheswarareddy
Hi Mahesh, I have similar requirement to convert the JSON response to XML with below structure having tables, columns and rows. Bit complicated JSON structure. Will it be possible to convert it into XML structure having the coloumn and rows values correspondingly using the standard receiver adapter.
{"outputs":
{"Result_Code":null,
"Result_Error":null,
"Result_Message":null},
"tables":[
{"columns":
["Workcenter_Code","Part_No","Job_No","Operation_Code","Log_Date","Workcenter_Status","Duration","Op_No","Update_Date","Shift"],
"rows":[
["S_A114M1","6026581","7603942","Laserschweißen (laserweld)","2023-07-01T05:00:00Z","09 Aus (Off)",8.00000,10,"2023-08-30T09:57:00Z","3rd"],
["S_A114M1","6026581","7603942","Laserschweißen (laserweld)","2023-07-03T13:00:00Z","09 Aus (Off)",8.00000,10,"2023-08-30T09:57:00Z","2nd"],],
"rowLimitExceeded":false}],
"transactionNo":"258654"
}
Hi Stefan,
Your conversion of JSON to XML format depends upon what operation you would like to perform on the http webservice.
If you simply want to fetch the JSON payload and convert it into XML then please use "Character Set Name" as "GET Variable" instead of UTF-8.
Regards,
Souvik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
21 | |
9 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.