【发布时间】:2016-10-14 13:59:45
【问题描述】:
我在 Oracle MAF 中使用 RestServiceAdapter 来调用 Restfull 服务,我想为服务设置超时,因为我在存在网络连接时遇到问题(例如:信号低、接入点连接错误等),所以应用程序变得很奇怪,它尝试执行请求,然后以奇怪的行为挂出。
这是我的代码,运行良好,但如果花费的时间超过 X 秒,我会抛出异常。
public String getJSONResponse(String baseUrlService) throws Exception {
try {
RestServiceAdapter restServiceAdapter = RestServiceAdapterFactory.newFactory().createMcsRestServiceAdapter();
restServiceAdapter.clearRequestProperties();
restServiceAdapter.setConnectionName(REST_STORE_CONNECTION);
restServiceAdapter.setRequestURI(baseUrlService);
restServiceAdapter.setRequestMethod("GET");
//Base 64 de Autenticacion de Weblogic real usuario 'Basic store-rest-user:password'
restServiceAdapter.addRequestProperty("Authorization", "Basic " + loginBase64);
//restServiceAdapter.setRequestType(RestServiceAdapter.REQUEST_TYPE_GET);
String response = restServiceAdapter.send("");
return response;
} catch(Exception e) {
throw new Exception("Error: problema de conexión o problema en servidor");
}
}
【问题讨论】:
标签: oracle-adf oracle-maf maf