


It consists of an HTTP inbound endpoint configured to handle requests on port 8081, an APIKit Router, and a Reference Exception Strategy. To implement the above-proposed scenario, we define the RAML contract containing the POST operation for the resource “file,” something like:įor a resource like this, we can have the following HTTP request example:īelow, I explain the flows that make up the Mule project of the REST API, which is running as Mule 3.8.1 EE runtime: You are able to do all of this before you make a minimal implementation available to run on some server. Using ready-made infrastructures, such as the Mulesoft’s Anypoint API Designer, the consumer can also test this RAML by generating an endpoint with mock information (provided in the RAML itself), testing the consuming part of the interface. Similar to WSDL s, when we define and make available a RAML, we give our consumers a better chance to prepare for it, as well as identify difficulties and provide suggestions for improvements for future versions of the contract. Defining a RAML contract is one of the ways to establish guidelines that favor the construction of a REST API which offers simplicity and stability from the start. When defining any type of API, we should consider that, when making use of any interface, consumers usually expect to find availability, simplicity, and stability. Implementation – Porting the Solution to REST API I thought that some of the advantages identified in the architecture applied in the legacy solution context, and so I built a way to port this architecture to a REST API, applying also significant improvements. As a result, it will not be necessary to request additional information for the service consumer in addition, we can still do part of the treatment process internally, asynchronously, without prolonging the client response time or timeout.įinally, this strategy also provides server resource savings since there is no need to request additional information regarding the transaction in progress. This is very desirable because it conforms to one of the great features of the HTTP protocol (which was designed to be Stateless) and allows the transaction to be completely processed in one request. All of this is in a single request handled by the service, which is very important for the processing economy and helps avoid maintaining and/or managing transactions handled by the service, in other words, it conforms to the Stateless behavior. Since all the necessary information is in the same payload, the process of reading and/or parsing the message is simplified. There is an advantage to using this strategy, which is the ability to transmit this tag in the same payload that may contain other information, such as the data needed to process business rules, or better still contain the meta information of the file. Figure 1Īfter the conversion, the String is deposited inside an XML tag, which is part of the Body content of the payload that is being transmitted to the remote server. When we do not use MTOM with SOAP, and the files are transmitted as a MIME attachment of the payload (similar to the process of sending emails containing attachments ), the implementation of the protocol converts the contents of the file that needs to be transmitted, and the result of this conversion is also a binary string in the Base64 format. The project needed to transmit binary files in SOAP Web Services, without using MTOM. Just to contextualize, this strategy was inspired by the architecture of a legacy project that I needed to maintain. SOAP Legacy – Identifying Reusable Concepts This guide will demonstrate one strategy, among many, to implement this integration scenario using resources provided by Mule components. This sounds like a challenge, doesn’t it? Perhaps some additional information for performing business logic processingīut we would like all this information to arrive on the server in the same request.The meta information related to it (e.g., name, content type, size and so on…).Sometimes we need to expose, in our REST API, an upload operation that allows the transmission of:

In the context of web applications, we call “upload” the process in which a user sends data/files from a local computer to a remote computer. This post was written by one of the stars in our developer community, Thiago Santana.įile-sharing is one of the most elementary ways to perform system integration.
