Search

Page tree
Skip to end of metadata
Go to start of metadata

This section explains the process of creating web service consumer activity for RESTful Web Service.

Steps to create Web Service Consumer activity for RESTful Web Service

  1. On the create Web Service Consumer page, select the REST radio button.

     

  2. Click Next. The values that you gave in the previous screen will automatically populate the Name and Description fields here.
  3. The Character Set Encoding field will display you the default character set encoding, you can define this at the application level. You can also change the character set encoding as per your requirements.
  4. In the URL textbox, enter the URL of the Web Service that you want to invoke.

    You need to pass the request in the URL.

    You can also define the values of the parameters in the Parameter table.

  5. To populate the Parameter table automatically from a URL, click the Extract Param from URL button. You can also populate the Parameter table along with their default values by giving the query parameters in the URL itself.

    You can dynamically override a complete URL or any parameter of the URL with the value of any variable. To do this you need define the variable name in the URL field.

    For Example, to override a complete URL you can define the URL as $$REST_URL_Var$$.





     Encryption Using Vault

    To encrypt the password using Vault, first create a vault and then use it to mask the password. It can either be used in the URL, or in the Parameter table. Write the aliasName and the key, which contains the confidential information (in this case- password) in the following format:

    {Vault.aliasName.key}

    where,

    • Following an opening curly parentheses, 'Vault' is a keyword (V in 'Vault' is UPPERCASE).
    • aliasName is the Vault Alias, where the parameter is defined.
    • key is the parameter which stores the password.
    • Finally closed by a closing curly parentheses.
    • A period is used as a separator between Vault and aliasName; and aliasName and key.

    With Vault, the URL format will be:

    http://server:host?username=<username>&password={Vault.aliasName.key}




    For example-
    http://localhost:8080?username=admin&password={Vault.safe.client_key}

    Instead of extracting parameters from the URL, you can also use Vault when you provide parameters directly in the table.

  6. Select the style of the parameters from the Style drop-down list. It could be Query or Header.

    If you want to pass parameters as a part of HTTP request then, you need to select Header in the Style drop-down list.

  7. Select a method from the Method field. You can select any of the following methods:
    • Get
    • Put
    • Post
    • Delete
    • Patch
  8. Define the Type and Media Type from the Presentation table as per you requirement.
  9. Select a security policy from the Security Policy drop-down list.

    When you use either Put  or Post method, then following two additional options are displayed.

    • Post Query String
    • Enable Multipart

    Post query string is used to pass the query paramters in RESTful Request.  To send the query  parameters with Put or Post method, enable the Post Query String option and define the parameters in the Parameter table. 

    Enable Multipart is used to the post the file to the RESTful Webservice.  To send a file follow the below steps:

    • Enable the Enable Multipart option.
    • In the Part Name field enter the name of the form-data field.
    • Enter the name of the file in the File Name  field. This name will be used for the file, which will be posted to the Web Service. You have to pass the file, which you want to send through this consumer, as a source stream. You use file source activity to achieve it.
    • Modify the media type in the presentation table as explained below
    • Media type for Request should be multipart/form-data

    Media type for Response varies for different web service.  It can be application/json or application/xml.

    Change Content Type of Multipart and Disposition Order

    To change the Content-type of multipart and disposition order, you need to set the following variables in the process flow:

    For Content Type: Service.{EntityName}.attachmentMediaType

    For Disposition Type: Service.{EntityName}.ReOrderContentDisposition = true

    here the EntityName is the web services consumer activity name, for example: Service.WeatherReport.attachmentMediaType=application/xml


    To send one or multiple payloads along with the file,

    Define the Context Variable Service.<Consumer Entity Name>.multipartParams in the Process Flow.

    If you have only one payload to be sent, you can alternatively define the following Context Variables in the Process Flow.

    • multipartRequestBody
    • multipartRequestBodyType

    multipartRequestBody - Enter payload as the value for this variable.

    multipartRequestBodyType - Enter the media/content type of payload as the value for this variable.

    Once defined, you can pass the payloads (in key-value pairs), separated by comma, as the value to this Context Variable. Given below is the example of two payloads in key-value pair.

    param1=value1,param2=value2

    If the value for any of the keys contains a comma (,) or equal to (=) characters, wrap the value in another Context Variable, and override the value of the key with this Context Variable.

    For example, if you have a key named param2 and the value to it is version=1, define a new Context Variable Var1 with the value version=1. Then, override the value of param2 as shown below: 

    param2=$$Var1$$

  10. Expand Advanced Properties to view the advance property of the RESTful web service consumer activity.



  11. If you do not want your RESTful web service consumer activity to wait indefinitely for a response from a web service provider then, enter a timeout value in the Read Timeout (in seconds) text box. The default value is 0 which means your RESTful web service consumer activity will wait indefinitely for a response.

  12. If you want to enter a time within which your RESTful web service consumer activity should connect to a web service then, enter a timeout value in the Connect Timeout (in seconds) text box. The default value is 0 which means your RESTful web service consumer activity will wait indefinitely for a connection.
  13. Click Save.
  • No labels