Our MuleSoft app is built to interact with Scores data in Salesforce database. It is a RESTful API that allows us to perform CRUD operations on Salesforce objects. We use Code Builder to build the app and CloudHub to deploy it.
API Documentation (in review 🚧)
Postman Collection (in progress 👨💻)
CloudHub Deployment (outdated 🚧)
For development and testing purposes, we can run the app using MuleSoft Code Builder.
MuleSoft Code Builder is a modern development environment designed to simplify and streamline the process of building and deploying integrations and APIs. It offers both local and cloud-based versions.
Below we outline how to use the cloud-based version. If you want to setup the environment locally, you can check instructions here (succesfully tested only on macOS).
- Create Anypoint Platform Account.
- Go to the main dashboard.
- Under "Anypoint Code Builder", click
Get Started
button. - Accept the terms and conditions (if you agree).
- Click
Launch
button (if it's greyed out, refresh the page and wait). - Wait for the environment to get allocated and load. The first time it might take a while.
- Clone the repository:
- Click on the
Source Control
icon on the left sidebar. - Click on the
Clone Repository
button. - Select
Clone from GitHub
option (you will need you GitHub account later, so it's a preferred option). - Choose the repository
AmericaSCORESBayArea/salesforce-data-api
. - Click
Clone
button.
- Click on the
- Open the project.
- Create
local.properties
file in thesrc/main/resources/properties
folder.
http.host=0.0.0.0
http.private.port=8091
sfdc.user=integrationuser@americascores.org.scoresqa
sfdc.url=https://americascoresbayarea--scoresqa.sandbox.my.salesforce.com/services/Soap/u/48.0
sfdc.tkn=
sfdc.password=
typeform.clientid=1234
typeform.clientsecret=1234
typeform.tkn=1234
Please note:
- The
sfdc.tkn
andsfdc.password
fields are sensitive. Please contact the developers to get the values. - Production and Sandbox Salesforce URLs are different. The URL above is for the Sandbox environment.
- The
typeform.clientid
,typeform.clientsecret
, andtypeform.tkn
fields are not used as we are moving away from Typeform. You can leave them as is.
-
Add
-M-Denv=local
to Mule Runtime arguments:- Right-click on "Mule" extension (letter M) at the left sidebar.
- Click on the "Settings" icon (gear icon) at the top right corner of the extension window.
- Find "Mule › Runtime: Default Arguments" and add
-M-Denv=local
to the list of arguments:
-M-Dmule.forceConsoleLog -M-Dmule.testingMode -M-XX:-UseBiasedLocking -M-Dfile.encoding=UTF-8 -M-XX:+UseG1GC -M-XX:+UseStringDeduplication -M-Dcom.ning.http.client.AsyncHttpClientConfig.useProxyProperties=true -M-Dmule.debugger.test.port=8000 -M-Dmule.debug.enable=true console0 -M-Denv=local
-
Config Run and Debug settings.
- Click on the "Run and Debug" icon on the left sidebar.
- Click on
create a launch.json file
link (below the "Run and Debug" button). - In the "Select debugger", choose "Mule Xml Debugger".
-
Install Thunder Client extension.
- Click on the
Extensions
icon on the left sidebar. - Search for
Thunder Client
and install it.
- Click on the
-
Click on the "Run" button.
-
Verify that the app has started successfully.
-
Try the following request using Thunder Client:
GET http://localhost:8091/api-internal/contacts?firstName=John&lastName=Doe
Ta-da! You are now running the Mule app in the cloud-based environment. 🚀
- The API code is located in
src/main/mule/api
folder. - When changing the code, you need to restart the app. Use stop button, then run button. Restart button doesn't work.
- If anything stops working as expected, you need to reboot the virtual instance:
- Go to the Anypoint Code Builder dashboard
- Select
Manage your IDE
option. - Click on the
Reboot
button.
The local build performed during the run differs from the build performed during the deployment. When running the app locally, raml
files in local src/main/resources/api
folder are used. When deploying the app, the raml
files fetched from the Exchange are used. When building the app for deployment, the global.xml.anypoint
should be used instead of global.xml
. (handled by the local-build.sh
script)
To manually build the app for deployment, you need to execute the local-build.sh
script. Then, you can manually upload the generated .jar
file to CloudHub. Make sure the following properties are set in Mule Runtime secrets:
anypoint.platform.config.analytics.agent.enabled=
anypoint.platform.client_id=
anypoint.platform.client_secret=
keystore.password=
keystore.key.password=
sfdc.password=
sfdc.tkn=
typeform.clientsecret=
typeform.clientid=
typeform.tkn=
api.id=
env=