当网络与IPV6兼容时,我开发了一个Oracle MAF iOS移动应用及其失败的呼叫网络服务。
我使用下面的代码进行网络服务调用 -
String restPayload = "";
RestServiceAdapter restServiceAdapter = Model.createRestServiceAdapter();
restServiceAdapter.clearRequestProperties();
restServiceAdapter.setConnectionName("PortPassConn");
//set GET, POST, DELETE, PUT
restServiceAdapter.setRequestType(httpMethod);
restServiceAdapter.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
restServiceAdapter.setRequestURI(requestURI);
restServiceAdapter.setRetryLimit(0);
//variable holding the response
String response = "";
//set payload if there is payload passed with the request
if(payload != null){
//send with empty payload
restPayload = payload;
}
try {
response = (String) restServiceAdapter.send(restPayload);
} catch (Exception e) {
MessageUtils.handleError("We encounter server side error, "+ e.getLocalizedMessage());
//We encounter server side error, with http status code -
//log error
// Trace.log("REST_JSON",Level.SEVERE, this.getClass(),"invokeRestRequest", "Invoke of REST Resource failed for "+httpMethod+" to "+requestURI);
// Trace.log("REST_JSON",Level.SEVERE, this.getClass(),"invokeRestRequest", e.getLocalizedMessage());
}
将错误视为:
“我们遇到服务器端错误,网络无法访问。”