how to perform xslt transformation for input request in adapter

為{幸葍}努か 提交于 2019-12-02 08:01:15

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!