i have created a XSLT
for the WL.Server.invokeHttp
which gets the data from the backend server in XML format and performing transformation successfully. this adapter is used to get the data from backend server.
but while sending data to server in XML , as i am getting data in adapter as JSON , i need to transform it into XML using XSLT.
is there any provision in ibm worklight adapters that i can perform XSLT transformation for input request just the way i can do it easily while getting response from backend server.
Here i am explaining the return data ( i.e. response)
for example,
if i want to fetch data for all employees , i will invoke an adapter i.e. getEmpDetails
which is returning data in XML , but i don't want to display all the fields those are returning from backend server , so i am using XSLT to filter the specific data and my mobile app is consuming it in JSON so i am transforming into JSON format also.
Data from Server
<Employee>
<EmpName>Jhon Methew</EmpName>
<EmpId>1234</EmpId>
<EmpDepartment>Accounts</EmpDepartment>
</Employee>
<Employee>
<EmpName>James</EmpName>
<EmpId>4434</EmpId>
<EmpDepartment>Sales</EmpDepartment>
</Employee>
<Employee>
<EmpName>Anna</EmpName>
<EmpId>3344</EmpId>
<EmpDepartment>Business Development</EmpDepartment>
</Employee>
After transformation by assigning XSLT in adapter i am getting following data
"array":{
"employee":[{
"empname":"John Methew",
"empdept":"Accounts"
},{
"empname":"Anna",
"empdept":"Business Development"
}],
}
now if i want to add a new employee via createEmp
adatper then i need to pass the input request in JSON format from mobile to create a new employee, and my adapter needs to transfrom this request into XML ( here, i want an XSLT filter the way i am heaving in getEmpDetails
adapter ).
input request to create employee
"employee":{
"empname":"Rahul",
"empdept":"Softwares",
"empid":"4233",
"emppay":"20k"
}
adapter will accept the response and need to convert above JSON input request to XML , so i was asking is there any provision in worklight to transform incoming request ?
<Employee>
<EmpName>Rahul</EmpName>
<EmpId>4233</EmpId>
<EmpDepartment>Softwares</EmpDepartment>
<EmpPayment>20K</EmpPayment>
</Employee>