Representational State Transfer (RESTful) has gained widespread acceptance across the Web as a simpler alternative to SOAP- and Web Services Description Language (WSDL)-based Web services. RESTful web service uses architectures that use HTTP or similar protocols by restricting the interface to use standard operations like GET, POST, PUT, DELETE for HTTP. You can create Consumer/Provider activities with the RESTful Web Service using Adeptia Suit.
Creating Web Service Consumer Activity to Access RESTful Web Service
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
- On the create Web Service Consumer page, select the REST radio button (see Figure 355).
Figure 355: Create RESTful Web Service Consumer
- Click Next. The values that you gave in the previous screen will automatically populate the Name and Description fields here.
- 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.
- 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. - 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 (see Figure 356).
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$$.
Figure 356: Define Parameters - 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.
- Select a method from the Method field. You can select any of the following methods:
- Get
- Put
- Post
- Delete
- Define the Type and Media Type from the Presentation table as per you requirement.
- Select a security policy from the Security Policy drop-down list.
- To know how to create Security policy, please refer to the Creating Security Policy for Web Service section.
- To know how to create Security policy, please refer to the Creating Security Policy for Web Service section.
- RESTful Web Service Consumer, only supports basic authentication.
|
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.|
- Expand the Advanced Properties section to view the advance property of the RESTful web service consumer activity (see Figure 357).
Figure 357: Advanced Properties (RESTful Web Service Consumer Activity)
- 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.
- 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.
- Click the Save button.
Overriding RESTful URL
We can override the REST URL at run time by placing Put-Context-Var before Web Services REST Consumer Activity in the Process Flow.
Steps to override the REST URL:
-
-
-
- On the Adeptia Suite homepage, go to Develop > Services > Web Services > Consumer.
- Create a RESTful Consumer activity by using a dummy URL in the URL field (see Figure 358).
To know how to create RESTful Consumer, please refer to the [ Creating Web Service Consumer Activity to Access RESTful Web Service
Using RESTful Web Service#_Creating_Web_Service_10] section.
Figure 358: Create RESTful Web Service Consumer - Click Save.
- Create a Target Activity.
To know how to create a Target Activity, please refer to the Creating Target Activity section.
- On the Adeptia Suite homepage, go to Develop > Process > Process Flow.
- Create a process flow using the following activities in sequence (see Figure 359):
Server Entities
Description
Context Variable
Put-Context-Var
Consumer Activity
REST
Target Activity
Any
Figure 359: Create Process Flow
-
-
- Click hierarchy structure in the Repository View panel. Expand the Action list and select the put-context-var action to drag it to the Graph Canvas area before the REST Consumer Activity.
- Connect the put-context-var to the REST Consumer Activity.
- Right-click the put-context-var and select View Properties. Its properties are displayed in the Properties Panel in the Bottom Pane.
- Click the Edit button to edit the value of context variable. The Edit Context Variables dialog box is displayed (see Figure 360).
Figure 360: Edit Context Variables
- Click the Add Variable ( ) to add new context variable. The Context Variable Information screen is displayed.
- Select the Rest Consumer activity (which is to be overridden) from the dropdown list Activity Name. All variables of this Rest Consumer activity are listed in the dropdown list Variable Name (seeFigure 361).
Figure 361: Context Variable Information
- Select restURL variable from the dropdown list Variable Name.
- Enter the Url that you want to override during the run time, in the textbox Variable Value.
- Click Done to close the Context Variable Information screen. This takes the control back to the screen Edit Context Variables. The newly created variable is added to the list of existing context variables.
- Click Done to close the Edit Context Variables screen and return to Process Designer.
- Select your Target activity.
- Save the process flow and exit from Process Designer.
- Execute the process flow, this overrides the dummy URL provided at the design time.
|
There are two ways to override RESTful URL at the run time:
|
Create Web Service Provider Activity to publish RESTful Web Service
This section explains the process of creating web service provider activity for RESTful Web Service.
Steps to Use Web Service Provider Activity to Publish RESTful Web Service
- In Create Web Service Provider Screen, enter the name and description of the new Web Service Provider activity in the Name and Description textboxes respectively (see Figure 362).
In case the Web Services Provider activity contains characters which falls in character set encoding, other than the default character set encoding, then you can change this encoding in the Character Set Encoding textbox. By default, this textbox will display you the character set encoding that you have defined at the application level.
Figure 362: Create RESTful Web Service Provider
- Select the REST radio button for the Publish Type field.
- Enter the resource end path URL in the Resource End Path textbox. For example: /rest/WeatherForecast
- From the Process Flow Name drop-down list, select the process flow name that you want to trigger with this web service.
-
-
-
- The process flow, which you select here, should have Context Source and Context Target activity.
- The process flow, which you select here, should have Context Source and Context Target activity.
-
-
-
-
- The parameterName attribute of the context source should be restRequest.
- The parameterName attribute of the context target should be restResponse.|
- The parameterName attribute of the context source should be restRequest.
-
-
- To define the resource parameter, enter the name and default value of the parameter in the Name and Default Value textboxes respectively.
- Select the style of the parameter from the Style drop-down list.
For the parameters that you want to pass as a part of HTTP header, select the Header option in the Style drop-down list.
- To add methods to your activity, click on the Add Method button. This action will show you the Method Description screen (see Figure 363).
Figure 363: Define Method
- Select the type of method from the Method Type drop-down list. The method type can be PUT, GET, POST, or DELETE. As per the type of method that you select, you will see a corresponding content in the Presentation Table (see Figure 364).
Figure 364: Add Method
- To define the method parameter, enter the name and default value of the parameter in the Name and Default Value textboxes respectively.
- Select the style of the parameter from the Style drop-down list.
For the parameters that you want to pass as a part of HTTP header, select the Header option in the Style drop-down list.
- Set the Status Code and Media Type in the Presentation table as per the requirements.
- Select the security policy from the Security Policy drop-down list.
To know how to create Security policy, refer to the Creating Security Policy for Web Service section.
The RESTful Web Service Provider supports only basic authentication. - Click the Save button.
A lot of WSDL files by default come with a dummy endpoint that do not point to the actual location of the service, but instead contains a dummy link, for example -
http://example/servicename. This is because sometimes the WSDL file describes what the service looks like, but do not point where it is located. Therefore it should be possible to override the endpoint from within the Web Service Consumer configuration instead of having to do via the Process Designer.
11