-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This section will guide you through the installation and initial setup of the SFCC Web Service Library. By following these steps, you'll be able to integrate the library into your Salesforce Commerce Cloud project and start utilizing its powerful features.
Begin by cloning the repository or downloading the ZIP file to your local machine.
git clone https://github.com/dkatashev/sfcc-web-services.gitAlternatively, you can download the ZIP file directly from the GitHub repository releases and extract it to your project directory.
Add the lib_webservice cartridge folder to your project's source code.
-
Copy the Cartridge:
- Navigate to the
cartridges/lib_webservice/directory in the cloned repository. - Copy the entire
lib_webservicefolder to your Salesforce Commerce Cloud project.
- Navigate to the
-
Include in Cartridge Path:
-
Go to the Business Manager in your SFCC instance.
-
Navigate to
Administration > Sites > Manage Sites > [Your Site] > Settings. -
Update the cartridge path to include
lib_webservice(this framework has no dependencies and can be placed at the end):your_existing_path:lib_webservice -
Why Last?: By placing
lib_webserviceat the end of your cartridge path, you ensure that it doesnโt override any of your projectโs custom code, unless explicitly intended.
-
Deploy the lib_webservice cartridge to your SFCC instance:
-
Using WebDAV:
- Upload the
lib_webservicecartridge to the{version}directory on your SFCC instance via WebDAV.
- Upload the
-
Using Business Manager:
- Go to
Administration > Site Development > Code Deploymentin Business Manager. - Upload the cartridge ZIP file through the Business Manager interface.
- Go to
-
Using IDE:
- Use your IDEโs deployment tools to upload the cartridge directly to your sandbox instance.
To ensure that the installation was successful:
-
Test the Setup:
- Run a basic service to confirm that the library is functioning as expected. You can use the provided "Hello World" example to verify the integration.
Hereโs a quick example to verify that everything is set up correctly.
Create a new script in your project:
// cartridges/app_custom/cartridge/scripts/services/HelloWorldService.js
var RestService = require('*/cartridge/scripts/webservice/RestService');
var HelloWorldService = RestService.extend({
SERVICE_CONFIGURATIONS: {
default: 'example.rest',
},
});
module.exports = HelloWorldService;- Navigate to Administration > Operations > Services.
- Create a new service profile named
example.rest.profile. - Set up a new service credential called
example.rest.credentials:- Enter the service URL to a valid endpoint for testing, such as
https://jsonplaceholder.typicode.com/posts. - Configure any required authentication settings as needed.
- Enter the service URL to a valid endpoint for testing, such as
- Finally, create a new service named
example.rest, and assign the previously created profile and credential to this service.
Add a controller or job to execute the service and log the output:
// cartridges/app_custom/cartridge/controllers/HelloWorld.js
var server = require('server');
server.get('Show', function(req, res, next) {
var HelloWorldService = require('*/cartridge/scripts/HelloWorldService');
var result = HelloWorldService.fetch({
method: 'GET',
});
res.json({ result: result.object });
next();
});
module.exports = server.exports();Navigate to https://[your-site]/HelloWorld-Show to see the output from the service.
Now that you've successfully installed and verified the SFCC Web Service Library, you can explore the following sections to learn more:
- Architecture Overview: Understand the core components and structure of the library.
- Usage: Detailed documentation on using the library with different web services (REST, SOAP, SFTP, WebDAV, Email).
- Contributing: Learn how you can contribute to the project.