我想获取所有Salesforce对象的列表。 我找到了这个链接 http://wiki.developerforce.com/index.php/Enterprise_Describe_Global
但有一些问题:
1)缺少会话(无效的会话ID) 为了防止这种情况,我还在URL中附加了会话密钥,但是它也没有显示请求。
错误:内部服务器错误(500)
2)我找到了某个地方并添加了clientId以及会话标题但又没有响应。
错误:内部服务器错误(500)
网络请求的代码示例:
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('POST');
req.setHeader('content-type','text/xml;charset=utf-8');
req.setHeader('Content-Length','1024');
req.setHeader('Host','na1.salesforce.com ');
req.setHeader('Connection','keep-alive');
req.setHeader('soapAction', 'getObjects');
String url = 'https://na1.salesforce.com/services/Soap/c/10.0/session_key';
String str = '<?xml version="1.0" encoding="utf-8"?> '+
'<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:enterprise.soap.sforce.com\">'+
'<soapenv:Header>'+
'<urn:SessionHeader>'+
'<urn:sessionId>'+'session_ID'+'</urn:sessionId>'+
'</urn:SessionHeader>'+
'<urn:CallOptions><urn:client>CLIENT_ID</urn:client></urn:CallOptions>'+
'</soapenv:Header>'+
'<soapenv:Body>'+
'<describeGlobal></describeGlobal>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
req.setEndpoint(url);
req.setBody(str);
HTTPResponse resp = http.send(req);
system.debug('response:::'+xml_resp);
Session_ID : I got this value from UserInfo.getSessionID();
client_ID : I tried following values : UserInfo.getUserID();/Secret token
但我无法让它成为获得武器的完美召唤。
希望有人能帮忙......答案 0 :(得分:3)
为什么在Apex中使用出站Web服务调用? Apex使用Schema.getGlobalDescribe()
原生访问全局描述信息 - 这是一种 更好的方式来访问描述结果。
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_schema.htm包含从Apex调用此文件的完整文档。