Martini HTTP Functions
Martini offers robust HTTP functions, simplifying the creation and transmission of HTTP requests. These functions are available in the Http
class, providing extensive features for HTTP requests:
Features:
- Configuration options for headers, cookies, redirect behavior, and timeouts.
- Automatic conversion between various data formats (JSON, XML, YAML) and Martini data models.
- Support for multiple authentication methods (Basic, OAuth1, OAuth2, Hawk, AWS4).
- Integrated tracking of request and response data for logging in Martini's Tracker.
Service Generation:
Utilize Martini Desktop's "Export as Service" feature within the HTTP Client to transform HTTP requests into reusable services. This feature allows you to construct, test, and export HTTP requests as services with associated request and response models.
Usage:
For Groovy-based implementations, prefer using HttpClientFunctions
over these HTTP functions.
Logging HTTP Traffic:
Martini's HTTP client, built on Apache HttpComponents, allows detailed traffic logging. Set the logging level of org.apache.http.wire
to DEBUG to view traffic logs in the Martini console.
io.toro.martini.Http.http(...)
Function:
This function handles RESTful HTTP requests.
Parameters:
Property | Type | Description |
---|---|---|
request |
GloopModel , io.toro.martini.http.Request |
Details of the HTTP request. |
auth |
GloopModel , io.toro.martini.http.Auth |
Authentication information for the request. |
returnAs |
String |
Response return type (InputStream , String , byte[] , GloopObject ). |
responseType |
String |
Response content type (XML, JSON, Auto-detect). |
throwHttpExceptions |
Boolean |
Whether to throw an exception for 5xx HTTP responses. |
trackable |
GloopModel , io.toro.martini.tracker.Trackable |
Tracking options for the call. |
Return Value:
Returns a io.toro.martini.http.Response
Gloop model with the server's response data.
Usage:
Requires at least function
and uri
parameters in the request.
io.toro.martini.Http.soap(...)
Function:
For sending SOAP requests.
Parameters:
Property | Type | Description |
---|---|---|
url |
String |
URL of the SOAP web service. |
auth |
GloopModel , io.toro.martini.http.Auth |
Authentication info for the request. |
soapAction |
String |
Name of the SOAP action. |
style |
String |
SOAP request style (document or RPC). |
soapProtocol |
String |
SOAP version. |
messageHeader |
GloopModel |
SOAP message header data. |
messageBody |
GloopModel |
SOAP message body. |
trackable |
GloopModel , io.toro.martini.tracker.Trackable |
Tracking options for the call. |
Return Value:
Returns a io.toro.martini.http.Response
Gloop model with response data.
Required Properties:
Requires url
and soapAction
properties for successful request sending.