Trailhead, the free, fun and fast way to learn Salesforce, has new content. There is a new Advanced Admin Trail that features modules on Advanced Formulas (which is a new module), Event Monitoring and Lighting Connect. Keeping with the Lightning theme, there are modules on Chatter and Data Management within the Lighting Experience.
For those Star Wars and Force (.com) fans out there, check out Build a Battle Station App project. The intro in the first step had me laughing out loud and is worth a read. Best of all, if you complete this clicks not code project by December 31, 2015, you have the chance to win awesome prizes like a Play Station 4 or Sphero Robot, check out the full details.
If you have completed the Application Lifecycle management module, you will want to check out the updates made to it. Finally, the module that caught my eye and one I want to dive into more detail is the Apex Integration Services.
Apex Integration Services
With multiple clouds and thousands of AppExchange apps, there is a ton of functionality provided without ever needed to leave Salesforce. However, the value of your investment in the platform is magnified by the available integration methods into outside systems.
First, the basics of the module. The module has four units - a short introduction, REST Callouts, SOAP Callouts and Apex Web Services. The introduction covers the use of SOAP web service callouts, which use XML with a WSDL for code generation. Using REST (the preferred integration method) with JSON and HTTP callous is also reviewed. An example use case for REST callouts is using an external tax calculation service when calculating an Order total.
As with all things Salesforce, security is at the forefront. Don't forget to setup a Remote Site Setting to enable access to the end points you communicate with. If you haven't done it before, the unit includes detailed steps to walk you through the setup process.
Apex REST Callouts
This unit starts with an overview of HTTP, which helps explain how REST works. The idea is to get you into the back and forth flow as well as level set on terminology.
I found the table of common HTTP methods particularly helpful.
- GET = retrieve data identified by a URL
- POST = create a resource or post data to the server
- DELETE = delete a resource identified by a URL
- PUT = create or replace the resource sent in the request body
As with most of the trailhead modules, there are several hands-on exercises to work with. REST Callouts works on getting you familiar with JSON and how to deserialize and serialize objects in Apex.
Just like Salesforce and security go hand in hand, so does unit testing. Apex test methods do not support callouts and any testing using callouts will fail. Instead, you must "mock" the callout to specify the response to return in the test. In addition to Trailhead, I recommend checking out blog posts on test and mocking by Salesforce MVP Jesse Altman. His blog is the place I turn when I want to mock something.
Finally, apply what you have learned by creating an adapted version of the REST callout (including tests with mocks) used in the unit to earn your points.
Apex SOAP Callouts
While setting up SOAP requires more effort than REST callouts, the unit starts by introducing WSDL2Apex. This tool will automatically generate Apex classes from a WSDL document, helping save time. Now the WSDL2Apex parser is not perfect. There are certain WSDL complexities that can trip it up. Given what it can automate for you, it is worth a try.
Once you have the Apex classes generated, working with SOAP is similar to working with REST. You will need to mock your callouts in order to test. One slight difference is generated a mocked responses for WebServiceCallout.invoke. The unit does a nice job of working you through this process, step by step.
Keeping true to its Trailhead theme, the challenge for this unit requires using a ParkService SOAP service to find a nearby park.
Apex Web Services
The last unit takes a look at REST and SOAP calls from the opposite perspective. Rather than calling out to another system, expose your Apex classes as its own web service. All it takes is a few annotations and a decent amount of code.
While I won't spoil all the fun for you, the bulk of this unit is a walkthrough of creating an Apex REST service based on the case object. While there is a lot of code here covering GET, POST, DELETE, PUT, PATCH and testing, don't be intimidated.
This is a fantastic detailed, walkthrough of putting it all together. There is even a section on cURL, which is a command-line tool for getting or sending files user URL syntax. Having all of this information in one place saves a ton of time searching the internet for piecemeal articles. Be sure to give the challenge a try to put all your new-found skills to use.
Wrap-Up
If the various Apex Integration options have been a bit of mystery to you, be sure to check out this module. It does a good job of explaining the concepts while providing hands-on practice. Let me know which new module you like the best. Until next time, keep on learning.
No comments:
Post a Comment