For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
Need to parse the XML Reponse obtained from SOAP Webservice into JSON / Java Script object using node.js from MCS Custom API. Please help!
You should be able to use a XML parsing module. e.g.
https://www.npmjs.com/package/fast-xml-parser
There are some others out there too
Hi Tware,
The XML that comes into MCS is from the Oracle ERP Cloud service, so it has a lot of attributes and namespaces, when I tried the fast-xml-parser via browser, it gave me syntax issues. So, can I still use it from node.js ?
For eg., I need to parse this XML,
<env:Body>
<ns0:findItemAsyncResponse xmlns:ns0="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/">
<ns2:result xsi:type="ns0:DataObjectResult" xmlns:ns2="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/" xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:tns="http://xmlns.oracle.com/adf/svc/errors/" xmlns:ns0="http://xmlns.oracle.com/adf/svc/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Value xsi:type="ns1:Item" xmlns:ns6="http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/flex/egoItemEff/item/categories/" xmlns:ns7="http://xmlns.oracle.com/apps/scm/productModel/items/flex/item/" xmlns:ns8="http://xmlns.oracle.com/apps/scm/productModel/items/flex/itemGdf/">
<ns1:ItemId>Value1</ns1:ItemId>
<ns1:OrganizationId>Value2</ns1:OrganizationId>
<ns1:OrganizationCode>Value3</ns1:OrganizationCode>
<ns1:ItemClass>Value4</ns1:ItemClass>
<ns1:ItemNumber>Value5</ns1:ItemNumber>
<ns1:ItemDescription>Value6</ns1:ItemDescription>
<ns1:PrimaryUOMValue>Value7</ns1:PrimaryUOMValue>
</ns0:Value>
</ns2:result>
</ns0:findItemAsyncResponse>
</env:Body>
MCS will do the parsing for you when you use the SOAP connector. It is described here: https://docs.oracle.com/en/cloud/paas/mobile-cloud/mcsua/soap-connector-apis.html#GUID-D85E17C2-59D1-4FB7-AC18-BEB0B60A9…
Quote from the documentation:
"Provides automatic translation of JSON requests to XML and XML responses to JSON, enabling you to interact with SOAP services without having to work expressly with XML. In addition, it provides you with the ability to provide the SOAP envelope itself, giving you the choice of using XML or JSON."
End of Quote
Does the SOAP connector help you? That is the ideal way to connect to Oracle services.
If not, we can try to find another parser. The key is to find a parser that doesn't require compiled c libraries to run.
the parser we use right now, when we can't use SOAP Connectors are xmljson and xml2js. They run without issues in MCS
Can you send me a sample usage of xmljson and xml2js.
Because I am getting this error, when I try to use them.
Custom Code VM: We couldn't create the container because of error Error: Cannot find module 'xmljson'
Error Details
at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/mobile/mobile_ccc/custom_code_modules/2a7616b6-cd3d-48b8-ad08-5242c0292de0_16/customapi/customapi.js:6:33) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Domain.<anonymous> (/mobile/mobile_ccc/mcs-node-router/mcs-node-server.js:1143:24) at Domain.run (domain.js:221:14) at Object.<anonymous> (/mobile/mobile_ccc/mcs-node-router/mcs-node-server.js:328:15) at Module._compile (module.js:570:32) ect.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:3.
Did you add xmljson to your package.json? Did you run npm installl prior to zipping of the module?
Thanks Tware.. I tried installing and it looks like it is working now! Thanks for your help @"lonneke" @"Tware-Oracle" !!