if (storageEnabled) {
[...]
parameterValue = keyValueStore.get(storageKey);
[...]
}
if(parameterValue == null){
[...]
HttpRequest request = new HttpRequest(parameters);
HttpResponse response = HttpClient.doRequest(request, parameters);
parameterValue = response.getResponse(parameters);
[...]
if (storageEnabled) {
[...]
keyValueStore.add(storageKey, parameterValue,
storageExpirationTime);
[...]
}
}
[...]
DynamicConfigurationAttribute dcAttribute =
new DynamicConfigurationAttribute(parameterNamespace,
parameterName, parameterValue);
if (dcAttribute.isDynamicConfigurationAttributeComplete()) {
dcAttributes.add(dcAttribute);
}
[...]
Parameter name | Description |
---|---|
*class | DynamicConfigurationProviderHttpLookup |
*dc.attribute.name | The name of the attribute in the Dynamic Configuration where you want to save the value received by the lookup. |
*dc.attribute.namespace | The namespace of the attribute in the Dynamic Configuration where you want to save the value received by the lookup. |
*dc.http.request.url | The URL that should be called (http://... , https://...). |
dc.http.request.proxyHost | If you need to route the call via a proxy, enter the Host-name of the Proxy-server here. |
dc.http.request.proxyPort | If you need to route the call via a proxy, enter the Port of the Proxy-server here. |
dc.http.request.method | HTTP Method: Only GET or POST are implemented yet. Default is POST. |
dc.http.request.header.<custom> | If you need to add specific HTTP Header you can add them here. The <custom>-Tag has to be replaced by a custom name. As a value you can enter what you need, make sure to keep the following syntax: <httpHeaderKey>: <httpHeaderValue> e.g. If you need to add a SOAPaction you can do something like: ParameterName: dc.http.request.header.MySoapAction ParameterValue: SOAPAction: A_Custom_SOAP_ACTION |
dc.http.request.postdata | POST-Data is only available when you do a HTTP-Post. Enter the payload that you want to sent in the request. |
dc.http.request.connectiontimeout | HTTP connection timeout in ms, default is 60000s. |
dc.http.request.readtimeout | HTTP read timeout in ms, default is 60000s. |
dc.http.response.valuesource | It may happen, that the HTTP Response returns more information than you want to store in the dynamic configuration. This parameter accepts "Reqex" or "XPath". If set, the selected operation is applied on the HTTP-Response. |
dc.http.response.valuesource.xpath | If dc.http.response.valuesource=XPath, enter the Xpath of the value you want to have. |
dc.http.response.valuesource.regex | If dc.http.response.valuesource=Regex, enter the Regex of the value you want to have. |
dc.http.response.stringformat | It may also happen, that you need to format the token somehow before further use. This is just a simple String.format() operation on the http/xpath or regex result. [String.format(<your value>, value)] As an idea, you can enter something like "Bearer %s". |
dc.keyValueStore.enabled | As already mentioned above, the module is able to store the received token for subsequent calls. This is enabled by setting the parameter to true. Default is false. |
dc.keyValueStore.key | This parameter is optional and by default initialized with the Channel-ID. It is possible to make several channels use the same storage by using the parameter. This is useful if the same token can be used in several receiver channels. E.g. If you have multiple receiver channels pointing to the same host and all can share the same token. |
dc.keyValueStore.expirationTime | Enter a value in minutes. Default is 1 minute. |
dc.keyValueStore.clear | By setting this to "true", it will disable the KeyValueStore and removes the saved token. This is useful, if you need to remove a saved token for any reason. |
public class DynamicConfigurationProviderDemoSoftware extends
DynamicConfigurationProviderHttpLookup {
private static final String PARAMETER_USERNAME = "DemoSoftware.username";
private static final String PARAMETER_PASSWORD = "DemoSoftware.password";
private static final String PARAMETER_URL = "DemoSoftware.url";
@Override
public List<DynamicConfigurationAttribute> execute(Message message,
Map<String, String> parameters)
throws DynamicConfigurationProviderException {
String username = "";
String password = "";
String url = "";
for (Map.Entry<String, String> parameter : parameters.entrySet()) {
if(parameter.getKey().equals(PARAMETER_URL)) {
url = parameter.getValue();
} else if (parameter.getKey().equals(PARAMETER_USERNAME)) {
username = parameter.getValue();
} else if (parameter.getKey().equals(PARAMETER_PASSWORD)) {
password = parameter.getValue();
} else {
}
}
String postdata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soapenv:Header/>"
+ "<soapenv:Body>"
+ "<ns:Login>"
+ "<ns:userName>"
+ username
+ "</ns:userName>"
+ "<ns:password>"
+ password
+ "</ns:password>"
+ "</ns:Login>"
+ "</soapenv:Body>" + "</soapenv:Envelope>";
// Set default values if not already set by Module Parameter
if (!parameters.containsKey("http.request.url"))
parameters.put("http.request.url", url);
if (!parameters.containsKey("http.request.postdata"))
parameters.put("http.request.postdata", postdata);
if (!parameters.containsKey("http.request.header.soapAction"))
parameters.put("http.request.header.soapAction","SOAPAction: \"Login\"");
[...]
return super.execute(message, parameters);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 |