2. Goals of this Session
1. Tell you more about the new web services technology
available in 5.3 and why you should use it
2. Show you how to use the contract-based web services in
your projects, new and existing
3. Give you a glimpse at upcoming enhancements
4. Reason 1: Tight Coupling with UI
What if the Terms label was
renamed to “Payment Terms” ?
5.
6. Reason 2: Ease of use
• The design of “classic” web-services is highly influenced by integration services
and the screen command/actions model.
• Intuitiveness is not one of the strong points of this model
• Everything is a string
• Multi-dimensional arrays
• Some operations happen ”magically” (searches)
• Wizardry and black magic is needed (commit flag)
• Complexity of use doesn’t increase linearly with the complexity of usage scenarios
• Scenarios which seem basic like changing a customer code, adding a payment method end up
requiring knowledge of screen internals
• A lot of code is needed for very simple operations
11. Viewing and configuring endpoints
• Endpoints form the contract between Acumatica and the consumer of
the API
• Key concepts
• Interfaces and versions
• Top Level, Linked and Detail Objects
• Mappings
• Actions (and default action)
• Endpoint Service
• Maintenance Service
• A default endpoint encompassing the most common scenarios is
included; this service will be maintainted by Acumatica
13. Let’s write some code!
• Retrieving data
• GetList (retrieveFullEntities, ****Value types)
• Get
• Filtering
• Custom fields
• Creating/updating a record (Put)
• Deleting data
• Invoking actions (ex: Release)
• Long-running process status
14. Advanced topics
• Working with files
• Smart panels
• Mapped via adapters (App_CodeEntity)
• Adapters abstract custom/non-standard logic that would be
otherwise
• Existing examples: Shipment Detail, PO Receipt
• Dialogs
• In an action has a confirmation dialog, in most cases it will be
confirmed automatically without an adaptor
15. Packaging and publishing your own endpoints
• Using API to import schema via maintenance service
• Exporting to XML
• GetSchema/PutSchema
• Packaging schema via customization manager
16. Migration Strategy
• The classic web services API is not going anywhere and will
remain supported
• New ISV integrations should be built on the new contract-based
web services API – sometimes next year it will become
mandatory for solution certification
• Existing code can be migrated gradually; you can mix both
technologies in the same product (share session cookies to
avoid needing multiple logins)
• The existing web services API not going anywhere and will
remain supported
18. Endpoint Extensibility
• Benefits of extensibility
• Extensibility scenarios
• Add new fields
• Add new screens
• What to do until extensibility is available
• You should NOT modify the predefined endpoint shipping with the app
• Ask us to add field
• Copy paste endpoint definition -> but you’ll have to maintain the whole thing
• If custom field – use CustomFields collection
• For your own screens – you can create a separate endpoint for now
19. REST
• Comparison of SOAP and REST
SOAP REST
1 XML-based message protocol over HTTP Simply HTTP
2 All of the data is contained in the message itself Data is spread out over different parts of HTTP protocol
3 One URL (endpoint), resource being affected is defined by
message and SOAP Action
Different URLs for different resources (ideally, every resource is
reachable by unique and non-changing URL)
4 Always POST, actual call semantics are defined by SOAP
Action
Call semantics are defined by HTTP method (GET/PUT/POST/DELETE)
5 Return status code is always 200 OK, actual
success/failure/other semantics are expressed in message
Basic (common) semantics are expressed in HTTP status code and HTTP
headers
6 Request/response format is XML Request/response format is negotiable (usually JSON and XML)
7 Standard-defined schema definition (WSDL and XSD) No standard schema definition
8 Hard to call from browser-based JavaScript (have to
implement XML/SOAP parser)
Easy to call from browser-based JavaScript (JSON parser is built-in) and
“newer” languages like Ruby on Rails
9 Hard to introduce caching Can rely on HTTP-defined standards for caching
20. Wrap-Up
• Thank you to early adopters –
Kensium (PC Bennett) and
OzDevelopment (Descartes)
• Training Materials now available
on Acumatica University
• I210 Contract-Based Web Services
5.3
• Questions?
22. No Reliance
This document is subject to change without notice. Acumatica cannot guarantee completion of any future products or program
features/enhancements described in this document, and no reliance should be placed on their availability.
Confidentiality: This document, including any files contained herein, is confidential information of Acumatica and should not
be disclosed to third parties.
No Reliance
This document is subject to change without notice. Acumatica cannot guarantee completion of any future products or program
features/enhancements described in this document, and no reliance should be placed on their availability.
Confidentiality: This document, including any files contained herein, is confidential information of Acumatica and should not
be disclosed to third parties.
Editor's Notes
The first reason is coupling with the user interface. Consider this very simple example – you’re accessing the Terms field in your application.
What happens here is quite unpredictable – but one thing is sure…
YOUR INTEGRATION IS BROKEN!
- If you’re trying to read this field, you’ll get an empty result, but no error.
- If you try to update it, your application will throw an exception.
- If you decide to update the web service reference in your app – the code will no longer compile.
Big problem if you’re an ISV needing to support customers on multiple revisions of Acumatica, or if you’re simply a VAR that has built an integration for a single customer that you need to update!
For sure, there are workarounds to this problem – since the schema is just a map over internal fields, you can easily decide to cache the schema. But it’s cumbersome, and one day you need to update the schema, and then your code will no longer compile.
Mention all the quirks in this code (need to GetSchema, multi-dimensional array, need to specificy all the fields you want, conversion to decimal)
That’s it! Which one do you prefer?
The current API just isn’t well adapted to REST
Very strong industry trend toward REST
The main difference between Top Level and Linked is whether you can edit an object directly or not. There is some screen for contacts in Acumatica - thus, it's Top-Level. There is no screen for Address - so it's linked.
Default action is something that happens when you Put an entity. By default it's set to Save (so there can be no chance it's "not set"). And I actually don't know when it's useful to override it. Maybe never.
Add WSDL as AcumaticaDefaultInterface. AllowCookies = TRUE.
When explaining GetList
- Explain retrieveAllEntities parameter (linked objects (?), details not returned)
- start with c.CustomerID
- introduce StringValue (allows to differentiate between undefined and NULL, and also enabled search with special ****Search type)
- GUID that is returned: session-wide unique OID. If object has a NoteiD this is the GUId we will return, otherwise internal map to facilitate updating and remove any ambiguity when you make changes to a record.
RetrieveFullEntities – if false, you won’t get any details or linked objects
Mention that the entities reflect what was been configured in the endpoint – it is no longer related to the screen layout, and therefore renaming or moving a field won’t break the API
Put and default action: refer back to the GUID
All entities: http://windows-10.shared/AcumaticaDemo53Rest/entity/Default/5.30.001/Customer
By key: http://windows-10.shared/AcumaticaDemo53Rest/entity/Default/5.30.001/Customer/ABARTENDE
Search on other fields: http://windows-10.shared/AcumaticaDemo53Rest/entity/Default/5.30.001/Customer?LastModified gt 2016-01-01
Search text: http://windows-10.shared/AcumaticaDemo53Rest/entity/Default/5.30.001/Customer?MainContact/Email%20eq%20dean@bartending.con