Class HTTPServiceDefinition
Represents an HTTP Service Definition.
The HTTP Service will use the return value of the createRequest callback as the request body (if supported by the HTTP method). If this is an array of non-null HTTPRequestPart objects, then a multi-part request will be formed. Otherwise the object is converted to a String and used.
See also XML.toXMLString() and JSON.stringify(Object), which must be explicitly called if needed.
Deprecated:
This class is only used with the deprecated ServiceRegistry. Use the LocalServiceRegistry instead, which allows configuration on the HTTPService directly.
API Version:
No longer available as of version 19.10.
| Property | Description |
|---|---|
| authentication: String | Returns the authentication type. |
| cachingTTL: Number | Returns the caching time to live value. |
| encoding: String | Returns the request body encoding to declare. |
| outFile: File | Returns the output file, or null if there is none. |
| requestMethod: String | Returns the request method. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| addHeader(String, String) | Adds an HTTP Header. |
| addParam(String, String) | Adds a query parameter that will be appended to the URL. |
| getAuthentication() | Returns the authentication type. |
| getCachingTTL() | Returns the caching time to live value. |
| getEncoding() | Returns the request body encoding to declare. |
| getOutFile() | Returns the output file, or null if there is none. |
| getRequestMethod() | Returns the request method. |
| setAuthentication(String) | Sets the type of authentication. |
| setCachingTTL(Number) | Enables caching for GET requests. |
| setEncoding(String) | Sets the encoding of the request body (if any). |
| setOutFile(File) | Sets the output file in which to write the HTTP response body. |
| setRequestMethod(String) | Sets the HTTP request method. |
configure, getConfiguration, getServiceName, isMock, isThrowOnError, setMock, setThrowOnError
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- authentication: String
Returns the authentication type.
- cachingTTL: Number
Returns the caching time to live value.
See Also:
- encoding: String
Returns the request body encoding to declare.
- outFile: File
Returns the output file, or null if there is none.
- requestMethod: String
Returns the request method.
- addHeader(name: String, val: String): HTTPServiceDefinition
Adds an HTTP Header.
Parameters:
- name - Header name.
- val - Header value.
Returns:
- this HTTP Service Definition.
- addParam(name: String, val: String): HTTPServiceDefinition
Adds a query parameter that will be appended to the URL.
Parameters:
- name - Parameter name.
- val - Parameter value.
Returns:
- this HTTP Service Definition.
- getAuthentication(): String
Returns the authentication type.
Returns:
- Authentication type.
- getCachingTTL(): Number
Returns the caching time to live value.
Returns:
- The caching time to live value in seconds.
See Also:
- getEncoding(): String
Returns the request body encoding to declare.
Returns:
- Request encoding.
- getOutFile(): File
Returns the output file, or null if there is none.
Returns:
- Output file or null.
- getRequestMethod(): String
Returns the request method.
Returns:
- HTTP Request method.
- setAuthentication(authentication: String): HTTPServiceDefinition
Sets the type of authentication. Valid values include "BASIC" and "NONE".
The default value is BASIC.
Parameters:
- authentication - Type of authentication.
Returns:
- this HTTP Service Definition.
- setCachingTTL(ttl: Number): HTTPServiceDefinition
Enables caching for GET requests.
This only caches status codes 2xx with a content length and size of less than 50k that are not immediately written to file. The URL and the user name are used as cache keys. The total size of cacheable content and the number of cached items is limited and automatically managed by the system.
Cache control information sent by the remote server is ignored.
Caching HTTP responses should be done very carefully. It is important to ensure that the response really depends only on the URL and doesn't contain any remote state information or time information which is independent of the URL. It is also important to verify that the application sends exactly the same URL multiple times.
Parameters:
- ttl - The time to live for the cached content in seconds. A value of 0 or less disables caching.
See Also:
- setEncoding(encoding: String): HTTPServiceDefinition
Sets the encoding of the request body (if any).
The default value is UTF-8.
Parameters:
- encoding - Encoding of the request body.
Returns:
- this HTTP Service Definition.
- setOutFile(outFile: File): HTTPServiceDefinition
Sets the output file in which to write the HTTP response body.
The default behavior is to not write a file.
Parameters:
- outFile - Output file, or null to disable.
Returns:
- this HTTP Service Definition.
- setRequestMethod(requestMethod: String): HTTPServiceDefinition
Sets the HTTP request method.
Valid values include GET, PUT, POST, and DELETE.
The default value is POST.
Parameters:
- requestMethod - HTTP request method.
Returns:
- this HTTP Service Definition.