Object type: ClientObject
The representation of the http Client object type for managing resilient clients.
Methods
post | The |
put | The |
patch | The |
delete | The |
head | The |
get | The |
options | The |
execute | Invokes an HTTP call with the specified HTTP verb. |
forward | The |
submit | Submits an HTTP request to a service with the specified HTTP verb. |
getResponse | This just pass the request to actual network call. |
hasPromise | This just pass the request to actual network call. |
getNextPromise | This just pass the request to actual network call. |
getPromisedResponse | Passes the request to an actual network call. |
rejectPromise | This just pass the request to actual network call. |
post
function post(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
The Client.post()
function can be used to send HTTP POST requests to HTTP endpoints.
Parameters
- path string
Resource path
- message RequestMessage
An HTTP outbound request or any allowed payload
- mediaType string? (default ())
The MIME type header of the request entity
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
put
function put(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
The Client.put()
function can be used to send HTTP PUT requests to HTTP endpoints.
Parameters
- path string
Resource path
- message RequestMessage
An HTTP outbound request or any allowed payload
- mediaType string? (default ())
The MIME type header of the request entity
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
patch
function patch(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
The Client.patch()
function can be used to send HTTP PATCH requests to HTTP endpoints.
Parameters
- path string
Resource path
- message RequestMessage
An HTTP outbound request or any allowed payload
- mediaType string? (default ())
The MIME type header of the request entity
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
delete
function delete(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
The Client.delete()
function can be used to send HTTP DELETE requests to HTTP endpoints.
Parameters
- path string
Resource path
- message RequestMessage (default ())
An optional HTTP outbound request message or any allowed payload
- mediaType string? (default ())
The MIME type header of the request entity
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
head
The Client.head()
function can be used to send HTTP HEAD requests to HTTP endpoints.
Return Type
(Response | ClientError)The response or an http:ClientError
if failed to establish the communication with the upstream server
get
function get(string path, map<string | string[ ]>? headers, TargetType targetType) returns targetType | ClientError
The Client.get()
function can be used to send HTTP GET requests to HTTP endpoints.
Parameters
- path string
Request path
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
options
function options(string path, map<string | string[ ]>? headers, TargetType targetType) returns targetType | ClientError
The Client.options()
function can be used to send HTTP OPTIONS requests to HTTP endpoints.
Parameters
- path string
Request path
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
execute
function execute(string httpVerb, string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Invokes an HTTP call with the specified HTTP verb.
Parameters
- httpVerb string
HTTP verb value
- path string
Resource path
- message RequestMessage
An HTTP outbound request or any allowed payload
- mediaType string? (default ())
The MIME type header of the request entity
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
forward
function forward(string path, Request request, TargetType targetType) returns targetType | ClientError
The Client.forward()
function can be used to invoke an HTTP call with inbound request's HTTP verb
Parameters
- path string
Request path
- request Request
An HTTP inbound request message
- targetType TargetType (default <>)
HTTP response or anydata
, which is expected to be returned after data binding
Return Type
(targetType | ClientError)The response or the payload (if the targetType
is configured) or an http:ClientError
if failed to
establish the communication with the upstream server or a data binding failure
submit
function submit(string httpVerb, string path, RequestMessage message) returns HttpFuture | ClientError
Submits an HTTP request to a service with the specified HTTP verb.
The Client->submit()
function does not give out a http:Response
as the result.
Rather it returns an http:HttpFuture
which can be used to do further interactions with the endpoint.
Parameters
- httpVerb string
The HTTP verb value
- path string
The resource path
- message RequestMessage
An HTTP outbound request message or any payload of type string
, xml
, json
, byte[]
or mime:Entity[]
Return Type
(HttpFuture | ClientError)An http:HttpFuture
that represents an asynchronous service invocation or else an http:ClientError
if the submission fails
getResponse
function getResponse(HttpFuture httpFuture) returns Response | ClientError
This just pass the request to actual network call.
Parameters
- httpFuture HttpFuture
The http:HttpFuture
related to a previous asynchronous invocation
Return Type
(Response | ClientError)An http:Response
message or else an http: ClientError
if the invocation fails
hasPromise
function hasPromise(HttpFuture httpFuture) returns boolean
This just pass the request to actual network call.
Parameters
- httpFuture HttpFuture
The http:HttpFuture
relates to a previous asynchronous invocation
getNextPromise
function getNextPromise(HttpFuture httpFuture) returns PushPromise | ClientError
This just pass the request to actual network call.
Parameters
- httpFuture HttpFuture
The http:HttpFuture
related to a previous asynchronous invocation
Return Type
(PushPromise | ClientError)An http:PushPromise
message or else an http:ClientError
if the invocation fails
getPromisedResponse
function getPromisedResponse(PushPromise promise) returns Response | ClientError
Passes the request to an actual network call.
Parameters
- promise PushPromise
The related http:PushPromise
Return Type
(Response | ClientError)A promised http:Response
message or else an http:ClientError
if the invocation fails
rejectPromise
function rejectPromise(PushPromise promise)
This just pass the request to actual network call.
Parameters
- promise PushPromise
The Push Promise to be rejected