DEV Community

Cover image for FTP Service in SFCC - SFRA Architecture πŸ“ž
DanieleAurilio
DanieleAurilio

Posted on • Edited on

FTP Service in SFCC - SFRA Architecture πŸ“ž

Hi guys! πŸ––

Have you to work with FTP service but it is your first time?
Don’t worry about it, SFCC provide a class called LocalServiceRegistry, with this class you can managing some request like HTTP, FTP and SOAP.
First of all we have to create a service in business manager on SFCC.

Let’s create service credentials and service profile: πŸ› οΈ

Go to Administration -> Services

Here we have three tabs:

  1. Services;
  2. Profiles: here we can specify ms time-out after a maximum number of failed call.
  3. Credentials: here we have to setup service credential.

Now we go to setup service credential:

New Service Credentials

Go setup service profiles:

Pasted Graphic 1

And at the end we can setup Service:

Pasted Graphic 2

After created service in business manager we can write our service call:

  • Create a file under the path cartridge/scripts/service.

  • Require LocalServiceRegistry.

Pasted Graphic 3

LocalServiceRegistry.createService() accepts two parameters, first is the name of the service, second parameter passed is a config object were we create request and parse the response.
createRequest must have service passed as parameter, setOperation() method is exclusive for ftp service, you can find full list of operation you can execute Here
After in parseResponse you can manipulate response and its returned data, for example you can iterate response data.

As you have seen it isn’t difficult, indeed it is intuitive with LocalServiceRegistry class.

Now when you have to call this service you have to include it in a file and after use yourService.call();

Top comments (0)