2012-12-13 60 views
3

我們使用REST API從一個Salesforce組織向另一個Salesforce組織發出調用。這工作到11月底。我們沒有對受影響的類或配置進行任何更改。 現在,在向其餘api發送請求時,會出現一條消息:「無法通過代理隧道,代理返回」HTTP/1.0 503服務不可用「。 對其餘api的授權由會話完成。ID 沒有人有任何的想法是什麼問題force.com callout exception無法通過代理隧道

這裏剪斷代碼:

final String WS_ENDPOINT = 'https://login.salesforce.com/services/Soap/c/24.0'; 
final String REST_ENDPOINT = 'https://eu2.salesforce.com/services/apexrest/UsageReporterService'; 
final String USERNAME = '*****'; 
final String PASSWORD = '*****'; 

HTTP h = new HTTP(); 
HTTPRequest req = new HTTPRequest(); 
req.setMethod('POST'); 
req.setEndpoint(REST_ENDPOINT); 
req.setHeader('Content-Type', 'application/json'); 
req.setTimeout(60000); 
HTTP hLogin = new HTTP(); 
HTTPRequest reqLogin = new HTTPRequest(); 
reqLogin.setMethod('POST'); 
reqLogin.setEndpoint(WS_ENDPOINT); 
reqLogin.setHeader('Content-Type', 'text/xml'); 
reqLogin.setHeader('SOAPAction', 'login'); 
reqLogin.setTimeout(60000); 

reqLogin.setCompressed(false); 
// get a valid session id 
String sessionId; 
String loginSoap = '<?xml version="1.0" encoding="UTF-8"?>';  
loginSoap += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">';  
loginSoap += '<soapenv:Body>';  
loginSoap += '<urn:login>'; 
loginSoap += '<urn:username>' + USERNAME + '</urn:username>';  
loginSoap += '<urn:password>' + PASSWORD + '</urn:password>'; 
loginSoap += '</urn:login>';  
loginSoap += '</soapenv:Body>';  
loginSoap += '</soapenv:Envelope>';  
reqLogin.setBody(loginSoap); 

HTTPResponse respLogin; 
try { 
    respLogin = hLogin.send(reqLogin); 
} catch(CalloutException c){   
    return null; 
}  

System.debug('++++++'+respLogin.getStatus() + ': ' + respLogin.getBody()); 
Dom.Document doc = new Dom.Document(); 
doc.load(respLogin.getBody()); 
Dom.XMLNode root = doc.getRootElement(); 
String ns = root.getNamespace(); 
Dom.XMLNode bodyEl = root.getChildElements()[0]; 


if(bodyEl.getChildElements()[0].getName().equals('loginResponse')){ 
     sessionId = bodyEl.getChildElements()[0].getChildElement('result', ns).getChildElement('sessionId', ns).getText(); 
} 


// finished getting session Id  
    if(sessionId != null){ // login was successfull 
    req.setHeader('Authorization', 'Bearer ' + sessionId); 
    // serialize data into json string 
    UsageReporterModel usageReporterData = new UsageReporterModel(); 
    String inputStr = usageReporterData.serialize(); 
    req.setBody('{ "usageReportData" : ' + inputStr + '}');  
    // fire! 
    HTTPResponse resp; 
    try { 
    resp = h.send(req); 
    } catch(CalloutException c){    
     return null; 
    }    
} 

回答

1

我懷疑這會涉及到知識產權的變化對組織的一個還沒有被解決列入正確的白名單(或添加到「網絡訪問」對象)。將Salesforce作爲Salesforce我希望Salesforce.com支持可以提供幫助嗎?