QIE takes the HTTP call and organizes it in a XML message structure to help make getting this easy.
Here is the sample source message for the call "http://localhost:8089/test?givenName=Aritra&lastName=Kundu&dob=16121986&gender=Male":
<?xml version="1.0" encoding="UTF-8"?>
<Request>
<Content-Type><![CDATA[null]]></Content-Type>
<Method>GET</Method>
<RequestURI>/test</RequestURI>
<QueryString>givenName=Aritra&lastName=Kundu&dob=16121986&gender=Male</QueryString>
<RemoteUser>null</RemoteUser>
<RemoteAddress>0:0:0:0:0:0:0:1</RemoteAddress>
<RemoteHost>0:0:0:0:0:0:0:1</RemoteHost>
<RemotePort>62554</RemotePort>
<Headers>
<Upgrade-Insecure-Requests><![CDATA[1]]></Upgrade-Insecure-Requests>
<Accept><![CDATA[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8]]></Accept>
<Connection><![CDATA[keep-alive]]></Connection>
<Accept-Encoding><![CDATA[gzip, deflate, br]]></Accept-Encoding>
<User-Agent><![CDATA[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36]]></User-Agent>
<Accept-Language><![CDATA[en-US,en;q=0.8]]></Accept-Language>
<Cookie><![CDATA[QIE-SESSIONID-80=1pb24k7bqyf4s1ia3sql1b3tdn]]></Cookie>
<Host><![CDATA[localhost:8089]]></Host>
</Headers>
<Part>
<Upgrade-Insecure-Requests><![CDATA[1]]></Upgrade-Insecure-Requests>
<Accept><![CDATA[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8]]></Accept>
<Connection><![CDATA[keep-alive]]></Connection>
<Accept-Encoding><![CDATA[gzip, deflate, br]]></Accept-Encoding>
<User-Agent><![CDATA[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36]]></User-Agent>
<Accept-Language><![CDATA[en-US,en;q=0.8]]></Accept-Language>
<Cookie><![CDATA[QIE-SESSIONID-80=1pb24k7bqyf4s1ia3sql1b3tdn]]></Cookie>
<Host><![CDATA[localhost:8089]]></Host>
<Content/>
</Part>
</Request>
Here is a function to use in your script or as a published function:
function getQueryParameterValue(urlQuery,parameterKey,defaultValueIn) {
var defaultValue = (defaultValueIn && StringUtils.isNotEmpty(defaultValueIn)) ? defaultValueIn : '';
// 1. Validate that we have a URL Query string
if (StringUtils.isEmpty(urlQuery)) {
return defaultValue;
}
// 2. Validate that we have a parameterKey
if (StringUtils.isEmpty(parameterKey)) {
return defaultValue;
}
var parameterValue = defaultValue;
try {
var urlParts = StringUtils.splitByWholeSeparator(urlQuery, "?");
// If no "?", then treat the entire string as the queryParameters.
var queryParams = urlParts.length > 1 ? urlParts[1] : urlParts[0];
var keyPairs = StringUtils.splitByWholeSeparator(queryParams, "&");
// cycle the list of key-value pairs and find the parameter
// specified by the 'parameterKey' passed into this function
for (var i = 0; i < keyPairs.length; i++) {
var keyValueParts = StringUtils.splitByWholeSeparator(keyPairs[i], "=");
if (keyValueParts.length == 2 && StringUtils.equalsIgnoreCase(keyValueParts[0], parameterKey)) {
parameterValue = String(qie.urlDecode(keyValueParts[1]));
break;
}
}
} catch (err) {
throw "Failed to getQueryParameterValue: " + err;
}
return parameterValue;
}
Here is how to use that function in the channel:
var queryString = source.getNode("/Request/QueryString");
var givenName = getQueryParameterValue(queryString, 'givenName');
See also:
Handling HTTP requests and responses
Processing Requests in mapping nodes via HTTP Listener source node