0
我試圖在apex Salesforce中標註一個休息服務,但是當我從Salesforce調用時它不工作,已嘗試使用它ARC Chrome以及我製作的Java程序並且工作正常。 當我把最大超時時給我這個錯誤。common.apex.runtime.impl.ExecutionException:來自服務器apex的文件意外結束
common.apex.runtime.impl.ExecutionException:從服務器頂點意外的文件結尾
當我改變它沒有超時給我:
發生意外錯誤:讀取超時
所以我真的不知道發生了什麼我使用相同的邏輯腳本來標註另一個Rest Servi鈰和它工作正常。
這是我的鱈魚至今:
@future (callout=true)
public static void SendNitrosOautIncluded(Decimal cantidadNitros, String id_cuenta) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
try {
map<String, Endpoint__c> endPoints = Endpoint__c.getall();
Endpoint__c endPoint = endPoints.get('PtxAddNitros');
String endPointPtx= (String)endPoint.get('Endpoint__c');
System.debug(endPointPtx+id_cuenta);
//req.setTimeout(60000);
req.setEndpoint(endPointPtx+id_cuenta);
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json; charset=utf-8');
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject();
gen.writeNumberField('credits', cantidadNitros);
//MANAGE RESPONSE
String objSended= gen.getAsString();
System.debug(objSended);
req.setBody(objSended);
res = http.send(req);
String resp=res.getBody();
System.debug(resp);
System.debug(res.toString());
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
/* Map<String, Object> m =(Map<String, Object>)JSON.deserializeUntyped(resp);
System.debug(m);
//CONTROL DE ERRORES
String data=(String)m.get('data');
String status=(String)m.get('status');
if(status.equals('200')){
System.debug('CORRECTO');
}*/
} catch(System.CalloutException e) {
facturaDeudor.errorMessage(e);
}
}
問題在於防火牆,將URL的所有de地址放在服務器的白名單中進行標註並且它可以工作。 https://help.salesforce.com/articleView?id=000003652&type=1 – Kuidsh