This design scenario takes in a JSON request from a web service call made by an external system/application, converts the incoming request to a CSV file along with grabbing an image file specified by a URL in the JSON message and both are sent to an FTP site.
View the following video for a brief summary of the flow, detailed descriptions below, as well as attachments for the custom plugins and exported zip file that you can import into your own Adeptia Integration Suite instance.
1. Design the Flow in the Process Designer as seen in the figure above.
2. Configure the activities for each step.
a. Context Source – You do not need to create/configure this from Web Browser, but can be found within the Process Designer’s Repository View under Activities --> Source --> Context Source. See attached JSON message to send as test message.
In Process Designer, make sure the Context Source’s parameterName property is set to restRequest
b. JSON to XML Service – this is a Custom Plugin, CP_JSON_to_XML, service that can be created and managed under Services --> Extensions --> Custom Plugin. Please see following Adeptia Developer Forum post for details on how to create if needed: https://support.adeptia.com/entries/22064898-JSON-to-XML-and-vice-versa-
c. Create XML schema as the source and CSV schema as the target using the attached XML and CSV files to this forum post respectively. NOTE: XML Schema Activity is not needed as a separate step in the Process Flow Designer.
d. Data Mapping – map the XML to CSV and capture the URL in a variable to send to Custom Plugin, CP_FetchImage, to pull the actual image file at that URL. See attached XML to use as source schema. See attached CSV file to use as target schema.
Map the fields appropriately.
On the Record node of the destination schema, create a Local Variable and use the set-context function found under Context function menu.
Type in ‘imageURL’ as the first parameter in the set-context function.
Then, click on the right side of the comma and double-click on the “URL” source element to populate the XPath as the second parameter of the set-context function.
e. Use the Text Schema to “Create CSV File” after mapping activity
f. Load CSV File to FTP Site – Create FTP Target activity to send transformed CSV file to FTP site
g. Service to pull image – this is a Custom Plugin service, CP_FetchImage, that can be created and managed under Services --> Extensions --> Custom Plugin. Please see attached text file, Plugin_FetchImage.txt, that has Java script for this Custom Plugin. Make sure "Consume Stream" is set to "False" and "Generate Stream" is set to "True" in Process Flow Designer.
The imageURL in double-quotes in the following line of code is the variable value that was setup in the Data Mapper.
String imageURL = (String) context.get("imageURL");
h. Load Image File to FTP Site – load the image file to the same FTP site the CSV file was sent to.
i. Context Target – You do not need to create/configure this from Web Browser, but can be found within Process Designer’s Repository View under Activities --> Target --> Context Target. Send a JSON Response back to the requesting system/application.
In Process Designer, make sure the Context Target’s parameterName property is set to restRespone
j. Publish this Process Flow as a Web Service by going to Services --> Web Services --> Provider and create/configure the Web Service Provider activity.
Define the REST Publish Type, Resource End Path, and Process Flow Name of the Flow with all of the above activities.
Add a POST method and define json while highlight for the REQUEST and RESPONSE Presentation Types.
After completing and saving all of the configurations, you can click on View for your Web Service Provider activity to view the URL that an external system/application can call.
See the attached exported zip file (JSON_WebService_Flow) for all of the configurations for this design scenario that you can import into your own Adeptia Integration Suite instance.