+ Start a Discussion

Call to our Server



I need to develop a class in which i should be able to verify, if certain files or folder does exist in our network server from SFDC apex code.


so its like Apex code --> Files on our server(checking if they exisit)--> and update exisiting value in SFDC.


how do i connect to the server.


Any help would be greatly appreciated.


Thank you.


There's a number of methods you can use, depending on your exact technology features and development resources: Here are some that come to mind:


1) HTTP. You can use GET with If-Modified-Since to conditionally retrieve new content. You could call this on-demand or on a scheduled timer. This would be pure Apex Code, no programming is necessary on the network, but will need network configuration for firewalls and routing.

2) SOAP: You could create a web service for the network that can be queried similar to the first option. This requires code development both in Apex Code and a web supporting language, such as PHP or ASP.NET.

3) Service: You could create a network service that uses the salesforce.com Web Services API to push updates periodically. This requires no Apex Code, but will require coding in a software supporting language, such as Java or C++. Can be repeatable using Microsoft Task Manager, or cron for Unix-based systems.


Option 3 is probably the least amount of work, while option 2 is likely the most intensive. Option 1 is most likely closer to option 3 in terms of work required, but will probably require slightly more overall work considering the firewall and routing configuration necessary.


There are other methods you could use as well, such as SMTP delivery of network updates, which could be used with one of the options above, or, depending on the size of the files to transfer, could be handled directly within the email handler (e.g. the files are sent as attachments, and folders are sent as a list of file properties).


Overall, I don't see why you couldn't accomplish your ideas given the number of features possible. Just note that FTP is specifically not possible, as sessions must currently be non-interactive; a single HttpRequest services one sending of data (headers and content body) and one retrieval of data (the headers and response). FTP uses two ports and requires no less than 3 back-and-forth iterations (USER, PASS, and LIST or GET).




I should mention that if you want to use Apex Code, you'll probably need to read the documentation. The HTTP, HttpRequest, and HttpResponse objects (in the Apex Code Language Reference under Reference > Apex Classes > RESTful...) are the objects you will use for a REST setup. If you are creating a SOAP service, log in to your account and take a look at Setup > Develop > Classes; you'll see an option to import a WSDL. There's documentation on that, too. If you choose to use SMTP instead, you'd use the Messaging classes to handle the incoming emails. Configuration of the firewalls, routers, proxies, or any other technologies will depend on your organization's IT procedures and the configuration required by a given vendor. There's a wealth of information and available configurations, but it is up to you to determine the best method.