Skip to content

Toro Cloud Dev Center


examples package: Using generated HTTP client services

The examples package contains Data models and services, which use the Http class. These services were generated from the Export as Service feature in the Martini Desktop HTTP Client. They demonstrate how to make HTTP requests from Gloop. The generated models are in httpClient.model, and the generated services are in httpClient.services. The services were modified so they include additional steps relevant to achieve the desired flow of the program (e.g. error-handling).

Related articles

Please see the following articles for more information:

Try it!

In the Navigator, expand the examples package and navigate to the code folder, then expand the httpClient package. This package contains models, services, and API files, as shown below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
examples
├── ...
├── code
│   ├── httpClient
│   │   ├── mockApis
│   │   │   ├── postData
│   │   │   │     └── ReturnPostData.gloop
│   │   │   └── weather
│   │   │   │     ├── GenerateCurrentWeather.gloop
│   │   │   │     ├── GenerateRandomTemperature.gloop
│   │   │   │     └── GenerateWeatherForecast.gloop
│   │   │   └── HttpClientMockEndpoints.api
│   │   ├── model
│   │   │   ├── GetCurrentWeatherOutput.model
│   │   │   ├── GetWeatherForecastOutput.model
│   │   │   └── PostHelloWorldOutput.model
│   │   └── services
│   │       ├── GetCurrentWeather.gloop
│   │       ├── GetWeatherForecast.gloop
│   │       └── PostHelloWorld.gloop
│   ├── ...

Simply run the services under the httpClient.services package to see HTTP client services in action. You can also open these services to inspect their contents and read their line comments to understand them better1.

Logging HTTP traffic

The Martini HTTP client uses Apache HttpComponents to perform HTTP requests. If you would like to have the traffic from the client logged to the Martini console, change the logging level of the org.apache.http.wire category to DEBUG.

HTTP client logging set to debug

Explanation

The HTTP client services, which are under the httpClient.services package, use a function from the HttpMethods class to make HTTP calls. The services are configured to call the mock APIs defined in httpClient.mockApis.

Mock data only

The data generated by the services is mock data only.


  1. Open the Gloop service file to see comments. Make sure comments are also not hidden.