ashwinkm / Boomerang-app-support

Boomerang is an unique app which allows you to work with both SOAP & REST based web services.
10 stars 0 forks source link

IF Else in Soap Env request #39

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi

I am a first time user of this client and is trying test 'IF/ELSE' statement in a SOAP request but it's not working for me. It is not throwing any error so I think nothing wrong with the Syntax. However, I think issue is how I am checking conditions in IF statement as it always skips the code underneath in it. Have tried many syntax from google but none of them worked. I am sure I am missing something silly. Can anyone please share a sample code if you have done this before. Below is what I am trying:

test 123 test test dataextension true true true
ashwinkm commented 7 years ago

Are you trying to use environment variables in the request body?

Boomerang uses Mustache.js for string interpolation. You can use your environment variables in the request body like this:

...
 <ts:Name>{{variable_name}}</tsv:Name>
...

Mustache doesn't support if else condition. But it supports the inverted condition.

{{#repos}}<b>{{name}}</b>{{/repos}} //if repos variable has truthy value, this block will be rendered
{{^repos}}No repos :({{/repos}} // else this block will get rendered 

Please refer the Mustache docs for more info.

ghost commented 7 years ago

Hi Ashwin,

Thanks for looking into this!

Let me reiterate it to explain this case in a better way. I have declared environment variable in "SCRIPT" tab based on which, I would like to execute XML statement which is written in the body tab. As an example, code would be something like this:

------------------------Script Tab---------------------

boomerang.setEnvironmentVariable('Var1', "abc");

------------------------Body Tab----------

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" >

......... .................. * < if test="{{Var1}} = 'abc'> /*exedution below create request*/* ........... ........... ........ * /* other wise exedution below create request*/* ........... ........... ........ Also, I have another qq on how we could capture responses of a request and use that values to action next request. For example, i would like to create a folder and a file under that folder. Therefore, i first need to create a folder in the first create request which will return folderid/object_id in its response. I would like to capture that folder id in a variable and dynamically use that value to create a file in that folder in next create request. appreciate your time and response! Thanks. Best Regards, *Jitender Balyan* Campaign Analyst Loyalty and Customer Data - Woolworths Food Group Woolworths Limited *M *0404535672 *E **jbalyan@woolworths.com.au * 1 Woolworths Way Bella Vista NSW 2153 PO Box 8000 Baulkham Hills, NSW 2153 Mailpoint: WG - C5 TR 23/24B PLEASE CONSIDER THE ENVIRONMENT BEFORE YOU PRINT THIS E-MAIL woolworths.com.au | woolworthsrewards.com.au On 25 April 2017 at 02:08, Ashwin K wrote: > Are you trying to use environment variables in the request body? > > Boomerang uses Mustache.js for string interpolation. > You can use your environment variables in the request body like this: > > ... > {{variable_name}} > ... > > Mustache doesn't support if else condition. But it supports the inverted > condition. > > {{#repos}}{{name}}{{/repos}} //if repos variable has truthy value, this block will be rendered > {{^repos}}No repos :({{/repos}} // else this block will get rendered > > Please refer the Mustache docs > for more info. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or mute the thread > > . > -- CAUTION: This email, links and files included in its transmission by Woolworths Limited ABN 88 000 014 675 and its group of companies (Woolworths Group) are solely intended for the use of the addressee(s) and may contain information that is confidential and privileged. If you receive this email in error, please advise us immediately and delete it without reading or copying the contents contained within. Woolworths Group does not accept liability for the views expressed within or the consequences of any computer malware that may be transmitted with this email. The contents are also subject to copyright. No part of it should be reproduced, adapted or transmitted without the written consent of the copyright owner.
ashwinkm commented 7 years ago

You can write it like this.

------------------------Script Tab---------------------

boomerang.setEnvironmentVariable('Var1', "abc");

------------------------Body Tab----------

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" >
    <soapenv:Header>
        .........
   ..................

    </soapenv:Header>

    <soapenv:Body >

{{#Var1}}  /* if Var1 is defined and has value  */*
        <CreateRequest xmlns="xxxxxxxxxxxxxxx">
            ...........
            ...........
           ........
        </CreateRequest>
{{/Var1}}
{{^Var1}}  * /* else execute below create request*/*
        <CreateRequest xmlns="xxxxxxxxI">
            ...........
            ...........
           ........
        </CreateRequest>
{{/Var1}}
    </soapenv:Body>

</soapenv:Envelope>

Please note that currently there is no way to validate the value of variable like this Var1=='abc'.

and to retrieve the response of other request, please refer the Script docs.