Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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

Follow the steps below to create a REST Consumer:

  1. Click Configure > WEB SERVICES > REST Consumer.

  2. Click Create REST Consumer

  3. On the Create REST Consumer window, in the Name and Description fields, provide a name and description for REST Consumer. 



  4. 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.
  5. In the URL field, 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. If you are using an encoded URL, you need to define a variable Service.<Consumer Entity Name>.encodeURL and set its value to true in the Process Flow associated with the REST Consumer.
  6. To populate the Parameter table automatically from a URL, click the Extract Param from URL. 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.
  7. 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.

  8.  Select the HTTP method from the drop-down list of Method. You can select any of the following methods depending on what the application API supports:

    • Get
    • Put
    • Post
    • Patch
    • Delete

    GET is used to fetch data. POST is generally used to create or store new data, while PUT is used to update existing data. Patch is used to make minor changes or updates to the resource at the target location.
  9. Define the Type and Media Type in the Presentation table.

    Important

    Enter Media Type as text/plain for Type Response.
  10. Select a security policy from the Security Policy drop-down list.

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

    • Post Query String
    • Enable Multipart

    Post query string is used to pass the query parameters 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

  11. Expand the Advanced Properties and do the following:

    1. 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.

    2. 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.
    3. In the Project field, select the project.
  12. Click Save.

  • No labels