0
Designing custom REST and SOAP
interfaces on Force.com
Steven Herod, Technical Director (Australia), Cloud Sherpas
@sherod
Safe harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contai...
Steven Herod
Technical Director, Cloud Sherpas (Australia)
@sherod
http://limitexception.herod.net/
Agenda
• Use cases for custom interfaces
• Upsides and downsides
• Code walkthrough
• Best Practices
3 (example) use cases
• Multiple external parties need to log leads w/o duplicates
• Concern: 3rd Party needs to understan...
Benefits of going custom…
•

Transaction safety
•

•

Lower latency
•

•

Offers a narrow/specific interface that allows y...
Caveats
• Your ETL Tool may not understand custom REST/SOAP interfaces with
Salesforce.
•

An out of the box ‘Salesforce A...
For and against
A real life example
Public Internet user clicks this button on a Heroku
Based website or a Mobile app
Salesforce needs to ...
Class structure
sObjects
sObjects
sObjects
RestQuoteServiceV1

Defers to

QuoteService

DAOs
DAOs
DAOs

SoapQuoteServiceV1...
Best Practices
• Consciously design your API
• Think about it! Govern it! Consider every method/operation! Document it!

•...
Best Practices
• Use Apex Wrapper Classes as Data Transfer Objects
• Refrain from sending or expecting sObjects or you may...
Best Practices
• Manage your transactions explicitly
• Especially if you do exception trapping

• Use @future if you need ...
Finally… REST specific advice
• 1 Class per URL mapping = proliferation
• Don’t forget the Query String
• E.g. GET /LoanAp...
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.com
Upcoming SlideShare
Loading in...5
×

Designing custom REST and SOAP interfaces on Force.com

3,381

Published on

My Dreamforce presentation on Designing custom REST and SOAP interfaces on the force.com platform covering use cases, benefits, and best practices.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,381
On Slideshare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
34
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Designing custom REST and SOAP interfaces on Force.com"

  1. 1. Designing custom REST and SOAP interfaces on Force.com Steven Herod, Technical Director (Australia), Cloud Sherpas @sherod
  2. 2. Safe harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  3. 3. Steven Herod Technical Director, Cloud Sherpas (Australia) @sherod http://limitexception.herod.net/
  4. 4. Agenda • Use cases for custom interfaces • Upsides and downsides • Code walkthrough • Best Practices
  5. 5. 3 (example) use cases • Multiple external parties need to log leads w/o duplicates • Concern: 3rd Party needs to understand Salesforce and your data model semantics and logic. • Need to interact with a complex opportunity process/data model • Concern: An internal business process with many rules needs to be exposed to an external system. • Your mobile app needs to modify multiple parts of the data model to complete an action • Concern: ‘Chatty’ network traffic, opportunity for failures at any point.
  6. 6. Benefits of going custom… • Transaction safety • • Lower latency • • Offers a narrow/specific interface that allows you to expose only the aspects of the business logic and data model that are needed. More Robust • • Complete many activities in a single request Service Oriented • • Update multiple objects in a single request Can unit tested. Controlled interface • A published and controlled interface specific to your business.
  7. 7. Caveats • Your ETL Tool may not understand custom REST/SOAP interfaces with Salesforce. • An out of the box ‘Salesforce Adapter’ is not applicable here. (Generic REST / SOAP should work however) • You need to write code (and test coverage) • What was ‘no effort’ on the Salesforce side now becomes a Software Development process • Limits! • • • Request size (3MB) SOQL query limits (100 per request) Record modification limits(10,000 records touched)
  8. 8. For and against
  9. 9. A real life example Public Internet user clicks this button on a Heroku Based website or a Mobile app Salesforce needs to do this
  10. 10. Class structure sObjects sObjects sObjects RestQuoteServiceV1 Defers to QuoteService DAOs DAOs DAOs SoapQuoteServiceV1 Uses Uses QuoteModel QuoteRequest QuoteResponse
  11. 11. Best Practices • Consciously design your API • Think about it! Govern it! Consider every method/operation! Document it! • Fight for the user • Think: “What is easiest for the consumer of the interface?” • Work with the platform • Salesforce REST != REST purist • Salesforce SOAP != WS-* • Consider how you will manage testing with external parties • Test data, test system availability…
  12. 12. Best Practices • Use Apex Wrapper Classes as Data Transfer Objects • Refrain from sending or expecting sObjects or you may expose a lot of internal details • Use a Services layer • Keep your business code out of the class that handles the public interface. • Bake in versioning • Consider if you need to make a change to your interface • Unit test all the things • The unit test is your insurance and means you can detect when declarative changes affect your code
  13. 13. Best Practices • Manage your transactions explicitly • Especially if you do exception trapping • Use @future if you need to. • Shorten response times where its safe to go async • Indicate in the Apex Class name that is a public interface • Consider the error feedback • What does a API consumer see if things go wrong? • Program defensively • Expect bad input
  14. 14. Finally… REST specific advice • 1 Class per URL mapping = proliferation • Don’t forget the Query String • E.g. GET /LoanApplications/?daysSinceUpdate=5 • Watch your status codes and verbs! • Use the right status code and the right verb (GET, PUT, POST) Beep
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×