REST has quickly become one of the most popular ways of integrating services into your applications. Since Mendix 6.6.0, REST Services can be consumed natively within the platform. Furthermore, the necessary data mappings can be configured 100% visually, making your development life a lot easier.
In this webinar, we will show you how to fully leverage this exciting new feature set of the Mendix platform.
View past Expert Webinars on-demand at developers.mendix.com.
Q: Your table suggests that publishing REST services is not native to Mendix. Is this correct?
A: As of the current version of Mendix (6.8.0) publishing REST services is not natively supported yet. It is however on our roadmap and will likely be available in the future. This means that currently it is not possible to use the visual mapping capabilities available in the platform to publish REST services. There is however a REST Service module freely available in the app store that contains a comprehensive publishing feature-set. Also, in some situations you might be satisfied with using the OData publishing services, which have been available natively since version 5.18.
Q: Do you have any methodologies for how to use REST?
A: This really depends on the service you want to consume. There are however some general guidelines. To achieve robust integrations, it is very important to focus on how your application handles unexpected input from the other side. Questions to ask: have you implemented logic to gracefully deal with unexpected data being returned? Or no data at all? Can you handle unavailability of the consumed service in a way that makes sense to your users? Have you implemented proper error handling and logging to be able to troubleshoot in case the unexpected happens?
Q: How does the rest service works with a HTTPS (secure) connection? How do I have to work with the session key?
A: The platform supports the consumption of REST services over HTTPS without any extra effort. For authentication purposes we support HTTP basic authentication. Often, REST services provide a key to be supplied in the HTTP headers of subsequent requests to identify this prior authentication (often called a “session key”). We support the use of such HTTP headers in the platform.
Q: All entities created are non-persistable; how can I easily transform them to be persistable?
A: You can just open the domain model and double click the entity. There you will find the option “Persistable”, by switching it to yes you will achieve persistent storage of received objects in the database.
Q: If the search term had embedded spaces, how would you properly encode that - for instance 'Rolling Stones' as a search term
A: Often REST services expect such values to be URL encoded. To achieve this easily, you can use a Java action, such as the urlEncode action included in the Rest Service module.