I have a rest service that I am consuming. It has content-type ‘application/xml’. As I see in the simplifier documentation for connector calls, when the content type is ‘application/xml’, then the service will return the response with following 3 keys:
1)RESTBinaryResult – with the BASE64 encoded result body
2)RESTTextResult (returns only if it can be displayed as text)
3)content-Type – mime type of result body
I am not getting any clue, how can I extract the useful data from it. Do I need to decode this. If yes, please suggest how we can decode this type of response in simplifier.
Mathieu Roll
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)
Has successfully completed the online course Basics (100)
the best way to do this is using a business object.
Please find attached an example how to do this.
// read xml with connector
var result = Simplifier.Connector.TestXML.getXML().result;
output.result = result;
//convert RESTTextResult(xml) to javascript object
//convert xml to json
var RESTTextResultJSON = Simplifier.Util.xml2json(result.RESTTextResult);
//parse json to javascript object
var RESTTextResult = JSON.parse(RESTTextResultJSON);
//output data
output.RESTTextResult = RESTTextResult;
//convert RESTBinaryResult(base64) to javascript object
//convert base64 to xml
RESTBinaryResultXML = Simplifier.Util.decodeBase64(result.RESTBinaryResult);
//convert xml to json
var RESTBinaryResultJSON = Simplifier.Util.xml2json(RESTBinaryResultXML);
//parse json to javascript object
var RESTBinaryResult = JSON.parse(RESTBinaryResultJSON);
//output data
output.RESTBinaryResult = RESTBinaryResult;