【发布时间】:2014-09-06 13:40:44
【问题描述】:
任何人都可以分享通过 Salesforce 中的 Apex(Visual Force 页面和控制器)进行 JSON 网络服务调用的端到端示例。 就像我们在 HTML5 中所做的一样,Ajax 的 Jquery !
【问题讨论】:
-
用于 RestFul Web 服务和 SOAP Web 服务。
标签: json salesforce apex
任何人都可以分享通过 Salesforce 中的 Apex(Visual Force 页面和控制器)进行 JSON 网络服务调用的端到端示例。 就像我们在 HTML5 中所做的一样,Ajax 的 Jquery !
【问题讨论】:
标签: json salesforce apex
在调用 REST Web 服务的文档中有示例。
来自HTTP Classes:
public class HttpCalloutSample {
// Pass in the endpoint to be used using the string url
public String getContent(String url) {
// Instantiate a new http object
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
// Send the request, and return a response
HttpResponse res = h.send(req);
return res.getBody();
}
}
您可以将方法更改为以下之一:
GET、POST、PUT、DELETE、TRACE、CONNECT、HEAD 和 OPTIONS
HTTP (RESTful) Services 提供更完整的示例
不要忘记使用Remote Site Settings 来打开对目标域的访问权限。
对于 SOAP Web 服务,您可以define Apex classes from a WSDL。
【讨论】: