Portlet Factory, Version 6.1.2


 

REST Service Call builder variables and inputs

This topic describes the generated input variables and the inputs for the REST Service Call builder.

The following sections describe the generated input variables and the builder inputs.

 

REST Service Call input variable

This builder creates an input variable and schema based on the following criteria for the HTTP request parameters and body content.

 

Request parameters

Parameters that do not have a value specified in the builder inputs section are automatically exposed as inputs to the service call, and are included in the input schema. For example, if there is an HTTP parameter named Uuid specified without a value, the new input variable looks like the following:
<builderNameRestInputs>
   <Parameters>
      <Uuid>12345678</Uuid>
   </Parameters>
</builderNameRestInputs>

 

Body content

If the builder is setup to only POST/PUT body content (that is, there are no parameters) of type String, the generated input variable looks similar to the following code.
<builderNameRestInputs> 
   <BodyContent>body content value</BodyContent>
</builderNameRestInputs>

If your builder call only specifies a schema-typed body content, the XML input variable is created with the schema of the specified type.

 

Body content with request parameters

If the builder is setup to pass one or more parameters and body content is also specified, the new input variable looks similar to the following code.
<builderNameRestInputs>
   <Parameters> 
      <Uuid>12345678</Uuid> 
   </Parameters>
   <BodyContent> 
   ...... 
   </BodyContent> 
</builderNameRestInputs>

The body content can be either an XML structure or string value. The generated schema for the input variable reflects the entire structure.

 

InputStream content

A body content of type InputStream in all cases creates a separate input object type variable named with the following format.

builder_call_nameInputStream
For example, if your builder call name is uploadImage, the variable is named uploadImageInputStream. Typically, you manually initialize the variable object with the desired InputStream. For example, to POST the contents of a file, you can write a method that takes a file name as a parameter and performs the following operations.

  • Create an InputStream for the specified file.

  • Set the InputStream variable for the service call.

  • Invoke the service.
public void uploadFile(WebAppAccess webAppAccess, String fileName) throws FileNotFoundException 
    // Get the specified file
    File file = new File(fileName);
    InputStream inputStream = new BufferedInputStream( new FileInputStream(file));

   // Set the REST service InputStream input Variable.
   webAppAccess.getVariables().setObject("uploadImageInputStream", inputStream); 

   // Call the REST service DataServices/uploadImage/execute
   webAppAccess.processAction("uploadImage.invoke"); 
} 

Additionally, you can expose this method with a Service Operation builder to leverage the SOA architecture.

 

General Inputs

Table 1. General Inputs
Input name Description
Name Name for this builder call. The WebSphere Portlet Factory Designer displays this name in the builder call list.
HTTP Request Type Select the HTTP method to perform. The options are as follows:

POST

Add a new resource.

PUT

Update a known resource.

GET

Retrieve a known resource.

DELETE

Remove a known resource.
URL Enter the URL of the HTTP service to be invoked. This is a required input. Example: http://www.eclipse.org/home/eclipseinthenews.rss
Body Content Data Type Specify the body content data type of a POST or PUT operation. The content type can be a selected schema type, String, or InputStream. This input is only available if HTTP Request Type is set to POST or PUT.
Body Content Type Specify the body content MIME type of a POST or PUT operation. This input is only available if HTTP Request Type is set to POST or PUT. For example, text/xml.
Parameters Enter any optional parameters to pass to the service call.

Note: If the value for a parameter is left blank, the parameter becomes an input to the data service. This is useful when you use the View & Form builder to automatically generate an input page based on the service parameters.

User Name If the service requires basic user authentication, enter the user name to use for the request here.
Password If the service requires basic user authentication, enter the password for the specified user here.
Ignore Results Disable the handling of result data from a service. This is useful for operations that either do not return results or the results are not going to be used, for example, a DELETE.

 

Schema

Table 2. Schema inputs
Input name Description
Auto Create Schema Use this input to specify that this builder should automatically create a schema that describes the result data from the service call. Automatic schema creation is done by fetching sample data at model-generation time and building a schema from the sample data.

If the schema generated by this option is not suitable, you can use the Schema builder to create your own schema, and then select that schema by using the Reply Schema Type input.

Reply Schema Type

If the reply is expected to be XML, use this input to set the reply variable type to the type of a schema that is defined in the model. This allows the reply variable to be integrated with the Data Page builder. This input is only available if Auto Create Schema is not selected.

Restructure Feed Data

Enable the Restructure Type input, which allows you to select the type of restructuring to be performed. Restructuring the data makes it more suitable for use with the Page Automation builders. This input is only available when Auto Create Schema is selected.

Restructure Type

Use this input to select the type of restructuring to be performed. To extend this functionality, additional handlers can be registered by implementing the com.bowstreet.builders.webapp.methods.RestructureFeedData interface. For more information on registering handlers, see the com.bowstreet.builders.webapp.methods.RestructureFeedData Java Doc. The following are the default types for this input:

Simple Atom/RSS

Selecting this type wraps the Atom or RSS elements within an Atom or RSS element. If the result data is not an Atom or RSS feed, this input is ignored.

Auto

Selecting this type enables the automatic selection of the installed handlers. The current auto handlers include ones to restructure feeds for allowing easier consumption by Page Automation.
This input is only available if Restructure Feed Data is selected.
Include Attributes Add attribute definitions to the generated schema for any attributes found in the sample result data. This input is only available if Auto Create Schema is not selected.
Cache Schema Cache the schema that is generated by the sample data. Using this input, you can avoid doing an HTTP request to the service during every model generation. The cache key is made by using the following builder inputs: URL, HTTP Request Type, Restructure Feed Data, and Include Attributes.

If you change another input that effects the structure of the result data, clear this input, perform a regeneration, and set this input again. Setting this input provides the following benefits:

  • Enhanced performance

    This helps during editing models that contain this builder.

  • Enhanced security

    A cached schema avoids exposing model generation time credentials after you perform an initial regeneration. To leverage the security, set this input, enter the required credentials, and click OK. After you regenerate and save your model, clear your Sample Data Parameters from the builder inputs. The schema is now cached.

Sample Data URL Enter an alternate URL to use to fetch sample result data that is used to generate a schema. If this input is blank, the value specified in URL is used for the service.
Sample Data Parameters Enter an alternate set of parameters to pass to the service call. The parameters are used to fetch sample result data that is used to generate a schema.
Sample Data User Name Lets you enter an alternate user name for basic authentication to be used at generation time to create the result schema. If this input is blank, the value for User Name specified for the service is used.
Sample Data Password Lets you enter an alternate password for basic authentication to be used at generation time to create the result schema. If this input is blank, the value for Password specified for the service is used.

 

Advanced

Table 3. Advanced inputs
Input name Description
Timeout (seconds) Enter the number of seconds to wait for a response from the service. Default is 30.
Follow Redirect Enabled by default to follow URL redirections. To have the service request not follow any redirections, clear this checkbox.
Forced Content-Type Force the content MIME type of the result data to the appropriate value, for example, text/plain. Default is text/xml.
HTTP Headers Send additional HTTP headers in the request. In the HTTP header list, enter any HTTP header names and set the header values using the Choose Reference dialog, or enter a text string directly.

Note: Some services require that the client request appear to be a Web Browser. To conform to this requirement, you may need to set a User-Agent header. Example:

User-Agent Mozilla/4.5 RPT-HTTPClient/0.3-2
HTTP Cookies Enter the name for the cookie to include with the request or select the variable or method that contains or returns the cookie object. Due to the stateless nature of REST style services, cookies are not typically used.
Forward HTTP Cookies Optionally specify the names of the cookies to send from the client browser to the target service. For example, LtpaToken. By default, cookies are not forwarded.
Proxy Host Enter the host name or IP address of the HTTP proxy server for the current REST Service Call builder, which is used when data is fetched from the target server.
Proxy Port Enter the port number of the HTTP proxy server. Defaults to port 3128 if not specified.
Proxy User Enter the user ID to authenticate with the HTTP proxy server. The proxy server must be configured for Basic authentication to use this input.
Proxy Password Enter the password to authenticate with the HTTP proxy server. The proxy server must be configured for Basic authentication to use this input.
Use proxy at designtime Set to have the proxy used during design time generation when the REST service is called to build the schema.
Add Logging Enable logging of the requests inputs and the response. Information is written to the application server console and to the WebSphere Portlet Factory log file. Logged information can help in debugging problems with the service.

Parent topic: REST Service Call builder


Library | Support |