How to consume nested XML to CDT from web service?

Hello all,

I'm trying to call an integration object from SAIL. We should be able to use the data from the response in other interfaces and process models. The response is received in XML but has multiple nested fields (This is the only possible format). There are multiple approaches suggested and this is what we've done for them:

1. Parse XML Plugin

 -Installed the plugin successfully

-Received the response successfully in XML

-Converted from XML to JSON

-Converted JSON to Dictionary

local!response: rule!callToExternalService(),
local!json: xmltojson(local!response),
a!fromJson(local!json)

* Not entirely sure what the next step to turn this into a CDT would be

2. torecord()

-Received the response successfully in XML

-Tried to convert directly to CDT using torecord() but got an error

- Expression evaluation error at function 'torecord' [line 3]: Cannot convert XML to an internal value of type ServiceName@ServiceDetails).XML: {[Element: <soap:Envelope[Namespace:http://schemas.xmlsoap.org/soap/envelope/]/>]}

local!response:rule!callToExternalService().result.body,
torecord(local!response,ri!inputToPassCDT)

* I believe this error is due to the ri! being of the fault data type, I believe torecord() can only work with CDT's generated from XSD's but am unsure. If so, is there a simple way of copy/pasting the fault data type into an CDT? Else, do I have to recreate the fault data type manually? I would prefer this approach as it doesn't require a plugin but am unsure on how to proceed.

3. xpathsnippet()

*Haven't really started on this one but the idea was to parse the XML using xpath snippet & doc. Would this have any advantages/disadvantages over the other?

  Discussion posts and replies are publicly visible

Parents
  • Hello Oscar

    Between the options you are giving if i can pick I would suggest to use the torecord but before (after the call, before the torecord) use the xpathsnippet() to get the body and then convert to cdt. As a note all This works better if the service is rest.

    Looks like you are calling a wsdl,  I think we still have available the webservicecall, have you tried that ?

    Hope this helps

    Jose

Reply
  • Hello Oscar

    Between the options you are giving if i can pick I would suggest to use the torecord but before (after the call, before the torecord) use the xpathsnippet() to get the body and then convert to cdt. As a note all This works better if the service is rest.

    Looks like you are calling a wsdl,  I think we still have available the webservicecall, have you tried that ?

    Hope this helps

    Jose

Children
No Data