Learn by product

Select the product you would like help with:

Martini Logo
Select the product you would like help with:
Knowledge Base


How do I make my Gloop Service return dynamic output?

Modified on: Thu, 20 Sep, 2018 at 5:01 PM

You can make your Gloop services return dynamic output that can either describe a successful or an error response or anything you want your service to return. You'll be able to achieve it with just a very simple configuration.

Here's how you do it in fast and simple way:

  1. Create a blank Gloop service

  2. In your Gloop service head over to the Input/Output view, On the the right side is the output column, press dot key(.) then type obj
    and select the first entry that will appear from the content assist to create a new Gloop Object.

  3. On the left side we have the input column, press dot key(.) again to open up content assist, type in personBy default, an example package
    comes installed in your Integrate instance. Notice that you will get several suggestions upon typing person in the content assist.
    For this guide, we will be using streams.model.Person. Repeat this step and add velocity.model.Person. Rename both inputs to distinguish one
    from the other (person1 and person2 order doesn't matter).

  4. Your resulting input/output view should somewhat look like this

  5. Going back with your Gloop service, in the step editor, use content assist to quickly add a new Map Step
    (Insert a screenshot here that shows the added map step)

  6. Double click the Map Step to open up the mapper view. You should see the Gloop object we added earlier, double click it and a Set Expression Editor should appear. Type the code snippet that you will see in the screenshot below, make sure you have Evaluate checked to ensure that our input will be evaluated as a Groovy code snippet
    (Insert a screenshot that will show what was described in this step)

    (insert a screenshot that shows person1?:person2 typed in the editor)

  7. You would like to see how you will know if your service will return a dynamic response, so we're going to add something that prints in the console, again use the content assist by pressing dot(.) key and type in println. Several suggestions will appear so choose the one that has a single String parameter.
    (Insert a screenshot that shows what's the current state/look of the gloop service at this point)

  8. Double clicking the println service you added, will also open the mapper view. It will look a little bit different than when we first see the mapper view ui when we clicked on the Map Step we first added. Double click message on println's service input, a Set Expression Editor will appear. We can make our service to display a nice JSON string by typing object.asJson() and make sure the Evaluate option is checked

Did you find it helpful? Yes No

Can you please tell us how we can improve this article?