0

I want to read a specific value in the XML returned by the APIC Invoke policy (from a SOAP service), in a gateway script.

I have searched high and low. I have tried this and that from my searches. Result: I failed miserably.

I thought apim.readInputAsXML(function(error, xmlNodelist) was the answer, but was puzzled when I realised that I was reading the input to the API. I'm new to JavaScript and have concluded that 'xmlNodeList' I was processing was actually created by the 'readInputAsXML' (and not one I thought I was passing as parameter) Duh! I suppose the word 'input' gives it away.

I have found 'readAsXML()', but not what kind of object it operates on.

var xmlNodeList = apim.getvariable('response.body') seemed to work at first, and the type is 'object Nodelist', the same as when using 'readInputAsXML'.

However, the object returned by 'xmlNodelist.item(0)' is a blob (type=13). This contrasts with 'readInputAsXML', where this is a node with name 'Envelope'.

Can anyone help with an explanation or pointing me at a reference?

BTW, this is APIC 2018.3.7

Hummingtop
  • 25
  • 1
  • 7

1 Answers1

0

I came across a similar situation. Most likely the respone in api comes without a header, the content-type, so apiс does not know how to parse it. I advise that the response to api comes with content-type header. To access the message body, use the context variable message.body, which before the invocation contains the request, after the response.