Skip to content

Home

Development

IDEs

API Explorer

Releases

Release notes

Martini Runtime

Martini Desktop

Martini Online

Feature requests

Bug reports

HttpMethods

HttpMethods is a one-liner class that contains methods for making requests to a web service, either HTTP or SOAP, in Gloop1.

One of the most common transports used in applications, especially integrations, is HTTP. Because of this, Martini includes a one liner service that makes it easy to make a HTTP requests from Gloop. The one-liner is in the HttpMethods class, and contains everything you need to make an HTTP request including:

  • The ability to configure headers, cookies, redirect behaviour, and timeouts;
  • Automatic conversion of gloop models to json, xml, yaml (when requesting), and vice-versa (when parsing responses);
  • Multiple authentication methods (including basic, oAuth1 and 2, hawk, and aws4); and
  • Built-in tracking of request and response data, which allows the http call be be tracked

Calls to these one-liners can easily be dragged and dropped into your Gloop services just like any other one-liner, but you can also generate these Gloop services using the HTTP client in Martini Desktop Export as Gloop Service feature. Using this feature, you can construct and repeatedly test an HTTP request against a real endpoint in the HTTP client (like you would using a tool like Postman) before generating a service.

Once you're happy with the inputs and configuration of the request, you can export it. Exporting the request will create a new Gloop service which makes the equivalent HTTP request, along with the models required for the request and response. This effectively converts your custom request into a one-liner in itself!

For use in Gloop only

HttpMethods contains Gloop-specific methods; hence, are not recommended for use in Groovy. If you want to send requests in Groovy, use HttpClientMethods instead.

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

http

The io.toro.martini.HttpMethods.http(...) method is used for sending RESTful HTTP requests to a web server.

Parameters

Property Type Description
request GloopModel, io.toro.martini.http.Request A model containing the details of the request. The properties of this model will depend on the requirements of the receiving HTTP endpoint.
auth GloopModel, io.toro.martini.http.Auth A model containing the authentication information of the request.
returnAs java.lang.String The return type of the response. The response can be an InputStream, String, byte[], or a GloopObject.
responseType java.lang.String The content type of the response obtained; the options are: XML, JSON, or Auto-detect.
throwHttpExceptions java.lang.Boolean Indicates whether an exception should be thrown if the HTTP response code is 5xx.
trackable GloopModel, io.toro.martini.tracker.Trackable A model indicating the tracking options for the call; will be used by Martini's Tracker engine.

Return value

This one-liner will return a io.toro.martini.http.Response Gloop model which will contain the data sent back by the server as a response to the request.

Usage

Sample Gloop service showing how to use the `http(...)` one-liner of `HttpMethods`

The http(...) method requires at least two arguments

The http(...) one-liner requires you to at least provide the method and uri parameters in your request. Otherwise, Gloop will throw an error.

soap

The io.toro.martini.HttpMethods.soap(...) method is used for sending SOAP requests to a SOAP web server.

Parameters

Property Type Description
url java.lang.String URL of the receiving SOAP web service.
auth GloopModel, io.toro.martini.http.Auth A model containing the authentication information of the request.
soapAction java.lang.String The name of the SOAP action to call.
style java.lang.String Messaging style of the SOAP Request; it can be either document or RPC.
soapProtocol java.lang.String Indicates the SOAP version to be used.
messageHeader GloopModel Header data to be sent along with the request.
messageBody GloopModel The body of the SOAP message. This is the data inside the <soap:Body></soap:Body> element.
trackable GloopModel, io.toro.martini.tracker.Trackable A model indicating the tracking options for the call; will be used by Martini's Tracker engine.

Return value

This one-liner will return a io.toro.martini.http.Response Gloop model which will contain the data sent back by the server as a response to the request.

Usage

Sample Gloop service showing how to use the `soap(...)` one-liner of `HttpMethods`

Required properties

This method requires you to at least provide the url and soapAction properties in order to send a request successfully.


  1. More specifically, sending requests and mapping their response to models