Salesforce';上的Apex代码是否支持类似apache commons的HttpClient库;s Force.com平台?

Salesforce';上的Apex代码是否支持类似apache commons的HttpClient库;s Force.com平台?,salesforce,httpclient,apex-code,force.com,Salesforce,Httpclient,Apex Code,Force.com,我试图在Salesforce开发组织内使用Apex类执行外部Http REST API调用 我想知道是否有类似的HttpClient库的支持。有吗? 从文档中我意识到一种方法是使用System.Http类来执行请求。请参阅此处了解:和 例如: public class HttpCalloutSample { // Pass in the endpoint to be used using the string url public String getContent(Str

我试图在Salesforce开发组织内使用Apex类执行外部Http REST API调用

我想知道是否有类似的
HttpClient
库的支持。有吗?

从文档中我意识到一种方法是使用
System.Http
类来执行请求。请参阅此处了解:和

例如:

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();
    }
}
我问这个问题的原因是因为我记得在使用这样一个API的教程中遇到过一个Apex代码片段。我现在似乎找不到它


注:我知道Apex代码是一种不同的语言,像HttpClient这样的Java库不在Salesforce平台上运行。而且可能没有直接的语言级别的方法来集成它们,除非有一个Apex代码绑定到库

System.HTTP类和friends是从ApexCode发出HTTP请求的唯一方法。正如您所说,apex不是java,您不能在apex中运行随机java库。

System.HTTP类和friends是从ApexCode发出HTTP请求的唯一方法。正如您所说,apex不是java,您不能在apex中运行随机java库。

太好了。谢谢你的确认。现在我可以不再看了。:-)哇,我刚刚遇到了一个名为json2apex“”的工具。我在页面上看到了你的名字。让我的生活更轻松。很棒的工具,很棒的工作!伟大的谢谢你的确认。现在我可以不再看了。:-)哇,我刚刚遇到了一个名为json2apex“”的工具。我在页面上看到了你的名字。让我的生活更轻松。很棒的工具,很棒的工作!