I need to consume a REST service from Integration Server.
I currently do it is as follows:
Populate the content of the request in an IS document
Use pub.json:documentToJSONString to convert an IS document to a JSON representation
Use pub.client:http to make an HTTP request. The json string from the previous step is mapped to data/string. In order to have the right headers, I added content-type and Accept along with values to the headers input.
Is this the best way to do it in the current version (9.7)? Is it the only way?
Is this the best way to do it in the current version (9.7)? Is it the only way?<<<
It is indeed the way to do it if you are communicating with a non-IS server.
If you’re talking to another IS, you can use the (new in 9.7) com.wm.app.b2b.client.JSONClient. This class is very similar to com.wm.app.b2b.client.Context, which you may be familiar with, but it transmits JSON payloads rather than binary-encoded or xml-encoded IData.
Create a Document type on IS against which you want to validate the JSON.
Convert the inbound JSON to document using pub.json:jsonStringToDocument or pub.json:jsonStreamToDocument what ever is relevant.
Use pub.schema:validate and map your output document from Step-2 to “object” and set “conformsTo” as the document type you created in Step-1