The HTTP Client Connector enables greater control on HTTP sessions than the URL Connector provides. With the HTTP Connector we can set HTTP headers and body using predefined attributes. Also, any request to a server that returns data is available for the user as attributes.
This Connector supports secure connections using the SSL protocol when so requested by the server, for example when accessing a server using the 'https://' prefix in an URL. If client-side certificates are required by the server, we will need to add these to the TDI truststore, and configure the truststore in global.properties or solution.properties. More information about this can be found in the IBM TDI V7.1 Installation and Administrator Guide, in the section named "Client SSL configuration of TDI components".
The HTTP Client Connector does not support the Advanced Link Criteria (see "Advanced link criteria" in IBM TDI V7.1 Users Guide).
The HTTP client Connector can be used in four different AssemblyLine modes. These are:
In Lookup mode we can dynamically change the request URL by setting the search criteria as follows:
url equals $url
Base URL: http://www.example_page_only.com/lookup.cgi
Search Criteria:
name equals john mail equals doe.com
Resulting URL: http://www.example_page_only.com/lookup.cgi?name=john&mail=doe.com
When using the Connector in Iterator or Lookup mode the following
set of attributes or properties is returned in the Connector ("conn")
entry:
200 OK --->
200
200 OK --->
OK
When using the Connector in AddOnly mode the Connector transmits
any attribute named http. as a header. Thus, to set the content type for a request name the attribute http.content-type and
provide the value as usual. One special attribute is http.body that
can contain a string or any java.io.InputStream or java.io.Reader
subclass.
For all modes the Connector always sets the http.responseCode and http.responseMsg attributes. In AddOnly mode this
is special because the conn object being passed
to the Connector is the object being populated with these attributes.
To access these obtain the value in the Connector's After Add hook.
The HTTP Client Connector uses internally the HTTP Parser to parse
the input and output streams of the created socket to the specified
URL. The default character encoding used for this is ISO-8859-1.
If the HTTP Client Connector has a configured Parser, then this
parser is used to write the http.body attribute using its
specified character encoding; or, if not specified, the default character
encoding of the platform is used.
To explicitly specify the character encoding of the http.body attribute, use the Content Type parameter of the HTTP Client Connector.
For more information see Configuration.
The Connector has the following parameters:
If we use an https://
address, you might need to import a certificate as well.
You select a Parser from the Parser pane; select the parser by
clicking the top-left Select Parser button.
If specified, this Parser is used to generate the http.body content
when sending data. The parser gets an entry with those attributes
where the name does not begin with http. Also, this Parser (if specified) gets the http.body for
additional parsing when receiving data. However, do not specify system:/Parsers/ibmdi.HTTP, because a message body does not contain another message.
In your attribute map we can use the following assignment to post
the contents of a file to the HTTP server:
The Connector computes the http.content-length attribute
for you. There is no need to specify this attribute.
URL Connector,
var body = conn.getObject ("http.body");
var ch;
while ( (ch = body.read()) != -1 ) {
task.logmsg ("Next character: " + ch);
}
Consult the Javadocs for the InputStream classes and their
methods.
Character Encoding
Configuration
Examples
// Attribute assignment for "http.body"
ret.value = new java.io.FileInputStream ("myfile.txt");
// Attribute assignment for "http.content-type"
ret.value = "text/plain";
See also
HTTP Server Connector,
HTTP Parser.