AJAX Proxy

Some browsers don’t allow JavaScript code to connect to external servers directly. Therefore, you may need to send requests through the AJAX proxy.

To use the AJAX proxy, you must register all external services in the Salesforce user interface. From Setup, enter Remote Site Settings in the Quick Find box, then select Remote Site Settings.

For security reasons, Salesforce restricts the outbound ports you may specify to one of the following:

  • 80: This port only accepts HTTP connections.
  • 443: This port only accepts HTTPS connections.
  • 1024–66535 (inclusive): These ports accept HTTP or HTTPS connections.

Note

The AJAX proxy is part of the AJAX Toolkit. Access it using remoteFunction defined in connection.js. You can specify any HTTP method in remoteFunction, for example HTTP GET or POST, and it will be forwarded to the external service.

The following examples illustrate typical approaches for GET and POST:

GET Example:

1sforce.connection.remoteFunction({
2                   url : "http://www.myExternalServer.com",
3                   onSuccess : function(response) {
4                          alert("result" + response);
5                      }
6               });

POST Example:

1var envelope = ""; //request envelope, empty for this example
2            sforce.connection.remoteFunction({
3                   url : "http://services.xmethods.net:80/soap",
4                   requestHeaders: {"Content-Type":"text/xml",
5                          "SOAPAction": "\"\""
6                      },
7                   requestData: envelope,
8                   method: "POST",
9                   onSuccess : function(response) {
10                          sforce.debug.log(response);
11                      },
12                   onFailure : function(response) {
13                          alert("Failed" + response)
14                      }
15               });
  • remote Function Syntax and Parameters

    AJAX proxy uses remoteFunction to proxy calls.

  • Download the Salesforce Client Certificate

    Your application (endpoint) server’s SSL/TLS can be configured to require client certificates (two-way SSL/TLS) to validate the identity of the Salesforce server when it takes the role of client to your server. If so, you can download the Salesforce client certificate from the Salesforce API page.