Interface HttpProvider
-
public interface HttpProvider
Provider interface for applications that want to send HTTP requests.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpRequest
createRequest(String method, URL url)
Create a new outgoing HTTP request.OutgoingHttpRequestActivity
createRequestActivity(HttpRequest request)
Create a new outgoing HTTP request activity.OutgoingHttpRequestActivity
createRequestActivity(HttpRequest request, boolean endOnResponse)
Create a new outgoing HTTP request activity.byte[]
marshalRequest(HttpRequest request)
Marshal the HTTP request into a byte array that can be serialized (e.g., stored in a CMP field).byte[]
marshalResponse(HttpResponse response)
Marshal the HTTP response into a byte array that can be serialized (e.g., stored in a CMP field).OutgoingHttpRequestActivity
sendRequest(HttpRequest request)
Asynchronously send an HTTP request to a remote host.OutgoingHttpRequestActivity
sendRequest(HttpRequest request, boolean endOnResponse)
Asynchronously send an HTTP request to a remote host, optionally request the activity to stay alive after the response is received.HttpResponse
sendSyncRequest(HttpRequest request)
Synchronously send an HTTP request to a remote host and block until the response arrives or the request times out.HttpRequest
unmarshalRequest(byte[] b)
Unmarshal an HTTP request from the byte array.HttpResponse
unmarshalResponse(byte[] b)
Unmarshal an HTTP response from the byte array.
-
-
-
Method Detail
-
createRequestActivity
OutgoingHttpRequestActivity createRequestActivity(HttpRequest request) throws IOException
Create a new outgoing HTTP request activity.- Parameters:
request
- the request to send. The request will be sent to the endpoint specified in the request's URL.- Returns:
- a new
OutgoingHttpRequestActivity
activity object, the SBB must attach to this in order to receive the response asynchronously. The activity will automatically end when the response arrives. - Throws:
IOException
- if unable to create the activity, for example due to an UnknownHostException
-
createRequestActivity
OutgoingHttpRequestActivity createRequestActivity(HttpRequest request, boolean endOnResponse) throws IOException
Create a new outgoing HTTP request activity.- Parameters:
request
- the request to send. The request will be sent to the endpoint specified in the request's URL.endOnResponse
- iftrue
, the RA will automatically end the activity when the response arrives. Iffalse
, the activity must be ended explicitly usingOutgoingHttpRequestActivity.endActivity()
.- Returns:
- the
HttpResponse
received. If the request times out, the stack will return a 500 server error response. - Throws:
IOException
- if unable to create the activity, for example due to an UnknownHostException
-
createRequest
HttpRequest createRequest(String method, URL url)
Create a new outgoing HTTP request.- Parameters:
method
- a HTTP method string, e.g. "GET"url
- an HTTP URL containing the remote host and resource to retrieve- Returns:
- the new request object, ready to send.
-
sendRequest
OutgoingHttpRequestActivity sendRequest(HttpRequest request) throws IOException
Asynchronously send an HTTP request to a remote host.- Parameters:
request
- the request to send. The request will be sent to the endpoint specified in the request's URL.- Returns:
- a new
OutgoingHttpRequestActivity
activity object, the SBB must attach to this in order to receive the response asynchronously. The activity will automatically end when the response arrives. - Throws:
IOException
- if unable to send the request
-
sendRequest
OutgoingHttpRequestActivity sendRequest(HttpRequest request, boolean endOnResponse) throws IOException
Asynchronously send an HTTP request to a remote host, optionally request the activity to stay alive after the response is received. This is so that SBBs may attach to the activity and retrieve the response object in a subsequent transaction, without having to store response data in CMP fields.- Parameters:
request
- the request to send. The request will be sent to the endpoint specified in the request's URL.endOnResponse
- iftrue
, the RA will automatically end the activity when the response arrives. Iffalse
, the activity must be ended explicitly usingOutgoingHttpRequestActivity.endActivity()
.- Returns:
- a new
OutgoingHttpRequestActivity
activity object, the SBB must attach to this in order to receive the response asynchronously. - Throws:
IOException
- if unable to send the request
-
sendSyncRequest
HttpResponse sendSyncRequest(HttpRequest request) throws IOException
Synchronously send an HTTP request to a remote host and block until the response arrives or the request times out.- Parameters:
request
- the request to send. The request will be sent to the endpoint specified in the request's URL.- Returns:
- the
HttpResponse
received. If the request times out, the stack will return a 500 server error response. - Throws:
IOException
- if unable to send the request
-
marshalRequest
byte[] marshalRequest(HttpRequest request) throws IOException
Marshal the HTTP request into a byte array that can be serialized (e.g., stored in a CMP field).- Parameters:
request
- the request to marshal- Returns:
- a byte array with the marshalled data
- Throws:
IOException
- if unable to marshal the HTTP request to a byte array
-
unmarshalRequest
HttpRequest unmarshalRequest(byte[] b) throws IOException
Unmarshal an HTTP request from the byte array.- Parameters:
b
- the byte array to unmarshal- Returns:
- an HTTP request constructed from the data in the byte array
- Throws:
IOException
- if unable to unmarshal an HTTP request from the byte array
-
marshalResponse
byte[] marshalResponse(HttpResponse response) throws IOException
Marshal the HTTP response into a byte array that can be serialized (e.g., stored in a CMP field).- Parameters:
response
- the response to marshal- Returns:
- a byte array with the marshalled data
- Throws:
IOException
- if unable to marshal the HTTP response to a byte array
-
unmarshalResponse
HttpResponse unmarshalResponse(byte[] b) throws IOException
Unmarshal an HTTP response from the byte array.- Parameters:
b
- the byte array to unmarshal- Returns:
- an HTTP response constructed from the data in the byte array
- Throws:
IOException
- if unable to unmarshal an HTTP response from the byte array
-
-