examples
package: Gloop REST and SOAP APIs
Martini offers a simple, graphical way to expose APIs: Gloop APIs. Gloop REST APIs allow developers to easily expose RESTful web services to their clients; and likewise, Gloop SOAP APIs are available for easily exposing SOAP web services.
The examples
package shows how Gloop REST and SOAP APIs can be used in order to make
services (a Gloop service in this example) available over
HTTP. These Gloop APIs are named apis.restApi.HelloYou.api
and apis.soapApi.HelloYouSOAP.api
, respectively. Both
use and expose the apis.service.HelloYouService.gloop
service.
Related articles
Please see the following articles for more information:
Try it!
For the provided examples to work, the package must be running, and the APIs must be enabled. As long as these requirements are satisfied, you can execute requests against the published web services to confirm their availability.
If you would like to inspect and/or further configure the APIs, go to the Navigator, expand the examples
package, navigate to the code
folder, then expand the apis
package. This package will contain the Gloop REST and SOAP API files, and the service they both expose over HTTP:
1 2 3 4 5 6 7 8 9 10 |
|
Open the .api
files to inspect the details of the REST and SOAP APIs. Edit these APIs' fields as you see fit and save
to apply customizations.
Sending a REST request
To test the published RESTful web service, send a GET
request to /api/sample/hello/${name}
1.
There are multiple ways you can do this.
You can execute the following cURL command in your terminal:
1 2 3 |
|
You can create and send a request through Martini Desktop's HTTP Client using these steps:
- Open the
apis.restApi.HelloYou.api
file. - Click the Operations tab in the Gloop REST API editor.
- Right click the operation, and then select Invoke in HTTP Client from the appearing context menu.
- Click Send.
You can create and send a request through API Explorer using these steps:
- Open the
apis.restApi.HelloYou.api
file. - Click the Operations tab in the Gloop REST API editor.
- Click the API Explorer button from the toolbar.
- Expand the "Hello You" API on the left-hand side.
- Select the "GET /hello/{name}" operation.
- Click on the Try It Out! button.
- Click Execute.
If you have Postman installed, you can use it to invoke the REST API as follows:
- Open the
apis.restApi.HelloYou.api
file - Click on the Preview tab in the REST API editor.
- Select "postman.json" from the drop-down on the drop right.
- Right click on the provided URL, and select Copy Link.
- Open Postman, and click Import on the top-left.
- Select Import from Link, paste the URL, and then click Import.
- Open the newly imported operation, and click Send.
And the server will return a response similar to the following:
1 2 3 |
|
1 2 3 4 |
|
Sending a SOAP request
To test the SOAP endpoint, send a POST
request to /soap/apis.soapApi.HelloYouSOAP
.
1 2 3 4 5 6 7 8 9 10 11 |
|
The response will look something like:
1 2 3 4 5 6 7 8 |
|
No error message
There are no configured error responses for both REST and SOAP APIs in this example.
Explanation
You can easily expose Gloop services (and other types of services) via Gloop APIs. To create one, simply open the Gloop API wizard. After creating and configuring and saving your API, Martini will detect the mappings and your API will then be available for use.
-
${name}
is a path parameter and must be given a value. ↩