Question

We have a web service returning an array of data from a backend system and the service is integrated using an Adapter procedure.

On one machine, when the data is returned, i notice that the JSON object name that hosted the data is called "array". As such, when i want to access the data, i use invocationResult.array . All is well.

But when my colleague gets my code and run on her machine, the JSON returned from the adapter have "text" instead as the object name for the data. With this, my code essentially is giving out error as "array" is then became unidentified.

Why is it that the object name is different on different set of machine?

UPDATE My colleague machine runs version 6.1 Worklight Studio Plugin, while mine runs on 6.0. However another machine that runs with version 6.1 encountered no issue at all. Is this something to do with a Worklight settings?

Another info that i'm not sure will help or not, the problematic machine runs on Windows Server 2008 while others run on Windows 7 Professional

Was it helpful?

Solution 2

As it turns out, the problem lies in the adapter returnedContentType setting. The version on my colleague has a value 'plain' while the actual one should be 'json'

Many thanks to @Anton as it was his answer that pointed me to the correct direction.

OTHER TIPS

You're probably running a newer version of WL server/studio. WL adapters know how to process JSON responses. However in your case response is not JSON object, but an array. Older version of WL server treats it as plaintext, therefore you have a "text" property. Newer version of WL server knows how to handle arrays and interprets it as an array. The best approach here would be to use same lastest WL server/studio version on both machines. Alternatives might be manual conversion of array string to array object via JS APIs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top