how to perform xslt transformation for input request in adapter

前端 未结 1 839
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 08:51

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

相关标签:
1条回答
  • 2021-01-28 09:51

    XSLT is not converting XML to JSON. XSLT transforms XML into another XML not JSON.

    Once your adapter has retrieved XML from a backend the WL Server infrastructure will automcatically convert it to JSON. In case you have XSLT defined the original XML retrieved from a backend will first be translated into new XML according to XSLT and after that the new XML will be converted to JSON.

    There's no out-of-the-box APIs that can convert JSON object to XML string in WL adapters. You can follow two different approaches here

    1. Use 3rd party Java/JavaScript library to convert JSON to XML, e.g. https://code.google.com/p/x2js/ or http://www.json.org/java/. You can read more about using Java in adapters here http://www.ibm.com/developerworks/mobile/worklight/getting-started.html , search for "Using java in adapters"

    2. Manually create your XML templates and populate them with values from JSON. See page 18+ of http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v620/04_02_HTTP_adapter_-_Communicating_with_HTTP_back-end_systems.pdf. Use {myJsonObject.propertyName} to inject values to XML.

    0 讨论(0)
提交回复
热议问题