FTP Service in SFCC - SFRA Architecture 📞

danieleaurilio

DanieleAurilio

Posted on August 6, 2021

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();

💖 💪 🙅 🚩
danieleaurilio
DanieleAurilio

Posted on August 6, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related