Author Message
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
Hello,
Could you share with me magic commands which need to add for setup of HTTP timeout at REST request via variable?

Thanks a lot.
Best regards, Dmitry
P.S. I tried to scan forum but without result.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
If you are talking about the timeout set in the OD REST operation, you can take a look at the code in the Java class for the operation. There is a line like the following. That means there is a parameter named "RESTStock_1335991632130TimeoutSeconds" in the web.xml. This the only method available to set the time. If you want it more flexible, you would have to have multiple parameters configured in the web.xml and use a variable to set to a different parameter name. Change the method call to use the parameter from the variable.

setTimeoutSecondsFromParameter("RESTStock_1335991632130TimeoutSeconds");
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
Thank you for answer.
How to set time parameter from variable?
I remember usually there is special method for customizing settings.
Like this for database:
ConnectionProperties connProps = new ConnectionProperties();
connProps.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connProps.setUrl("jdbc:sqlserver://" + mySession.getVariableField(IProjectVariables.DBCONFIG,IProjectVariables.DBCONFIG_FIELD_URL).getStringValue());
connProps.setUser(mySession.getVariableField(IProjectVariables.DBCONFIG,IProjectVariables.DBCONFIG_FIELD_LOGIN).getStringValue());
connProps.setPassword(mySession.getVariableField(IProjectVariables.DBCONFIG,IProjectVariables.DBCONFIG_FIELD_PASSWORD).getStringValue());

setConnectionProperties(connProps);
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
As I said we only have this method for REST operation

setTimeoutSecondsFromParameter("RESTStock_1335991632130TimeoutSeconds")

You would have to add parameters with fixed timeouts into the web.xml.

For example, if you add a parameter called "REST_timeout_1", you can set the variable to "REST_timeout_1" and call the method like this:

setTimeoutSecondsFromParameter(mySession.getVariableFieldValue(myVar));
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
Thank you so much. It is better than nothing but only not convenient.
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
Hello,
This is not so clear. If I code as you recommended then this code will be remove during next save of the webservice.
Need to use something like:
@Override
public void setTimeoutSecondsFromParameter(String value)

but then need to know name of internal value for timeout.

Could you clarify?

Rg, Dmitry
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
I think I found it. It is timeoutSeconds.
Why I can't use @Override with this function?
Rg, Dmitry
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
It is a protected variable.
You could try overriding the getTimeoutSeconds(), and return the number of seconds you want. But this method does not have any context object like the session you can play with.
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
Thank you for your answer.
Your original idea with parameters from web.xml is not bad as well.
But for me it is not clear how to put block to java with protection from automatic save.
I mean need to put block with @Override but to work with setTimeoutSecondsFromParameter(String value).

As for last idea do you mean something like this?

@Override
public int getTimeoutSeconds() {

String timeout = mySession.getVariable(IProjectVariables.TIMEOUT).getSimpleVariable().getStringValue();

return Integer.parseToInt(timeout);
}
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
like this:

@Override
public int getTimeoutSeconds() {
return 60;
{

You have no access to mySession in the method.
DmitrySenashenko3
Joined: Aug 28, 2019
Messages: 62
Offline
But I believe I can set global variable during initialization of class.
And next to use this global variable at getTimeoutSeconds.
Is it correct?
Rg, Dmitry
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Yes, you can use your own class to provide some configurable variable if that's what you mean.
Go to:   
Mobile view