@ComponentProfile(summary="Make a HTTP request to a remote server using standard JRE components", tag="producer,http,https", metadata="adphttpresponse", recommended=NullConnection.class) public class StandardHttpProducer extends HttpProducer<java.net.HttpURLConnection,java.net.HttpURLConnection>
HttpProducer
implementation that uses HttpURLConnection
available in a
standard java runtime.
This uses com.adaptris.core.http.client
interfaces to manage request and response headers
and also the DataInputParameter
and DataOutputParameter
interfaces to source the
HTTP body and to handle the HTTP response body respectively. Without specific overrides for these
new fields then they default to the payload body.
Note that configuring a AdaptrisMessageEncoder
instance will cause the
DataInputParameter
and DataOutputParameter
fields to be ignored.
When interacting with HTTPS sites, then you may need to configure a truststore / keystore system
properties if non-default certificate handling is required. As this uses
HttpsURLConnection
under the covers; then please consult Oracles
JSSE documentation for a full discussion of the required system properties.
In the adapter configuration file this class is aliased as standard-http-producer which is the preferred alternative to the fully qualified classname when building your configuration.
DEFAULT_TIMEOUT
log
Constructor and Description |
---|
StandardHttpProducer() |
Modifier and Type | Method and Description |
---|---|
protected void |
doProduce(AdaptrisMessage msg,
java.lang.String dest)
Actually do the produce.
|
protected AdaptrisMessage |
doRequest(AdaptrisMessage msg,
java.lang.String endpointUrl,
long timeout)
Actually do the request.
|
java.lang.Boolean |
getAlwaysSendPayload()
Whether or not to always attempt to send the payload as the entity body.
|
@NonNull HttpAuthenticator |
getAuthenticator() |
TimeInterval |
getConnectTimeout()
The connect timeout.
|
TimeInterval |
getReadTimeout()
Set the read timeout.
|
DataInputParameter<java.io.InputStream> |
getRequestBody()
Set where the HTTP Request body is going to come from.
|
DataOutputParameter<InputStreamWithEncoding> |
getResponseBody()
Set where the HTTP Response Body will be written to.
|
void |
setAlwaysSendPayload(java.lang.Boolean alwaysSendPayload)
Whether or not to always attempt to send the payload as the entity body.
|
void |
setAuthenticator(@NonNull HttpAuthenticator authenticator) |
void |
setConnectTimeout(TimeInterval connectTimeout)
The connect timeout.
|
void |
setReadTimeout(TimeInterval readTimeout)
Set the read timeout.
|
void |
setRequestBody(DataInputParameter<java.io.InputStream> requestBody)
Set where the HTTP Request body is going to come from.
|
void |
setResponseBody(DataOutputParameter<InputStreamWithEncoding> responseBody)
Set where the HTTP Response Body will be written to.
|
defaultTimeout, endpoint, getAllowRedirect, getContentTypeProvider, getDestination, getIgnoreServerResponseCode, getMethod, getMethodProvider, getRequestHeaderProvider, getResponseHeaderHandler, getUrl, handleRedirection, ignoreServerResponseCode, logHeaders, prepare, setAllowRedirect, setContentTypeProvider, setDestination, setIgnoreServerResponseCode, setMethodProvider, setRequestHeaderProvider, setResponseHeaderHandler, setUrl, withURL
produce, produce, request, request, request, request
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
createName
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
close, init, start, stop
createQualifier, isTrackingEndpoint
protected void doProduce(AdaptrisMessage msg, java.lang.String dest) throws ProduceException
RequestReplyProducerImp
doProduce
in class RequestReplyProducerImp
ProduceException
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String endpointUrl, long timeout) throws ProduceException
RequestReplyProducerImp
doRequest
in class RequestReplyProducerImp
ProduceException
public DataInputParameter<java.io.InputStream> getRequestBody()
The default is PayloadStreamInputParameter
.
public void setRequestBody(DataInputParameter<java.io.InputStream> requestBody)
The default is PayloadStreamInputParameter
.
public DataOutputParameter<InputStreamWithEncoding> getResponseBody()
Note that if you have configured an AdaptrisMessageEncoder
via
AdaptrisMessageWorkerImp.setEncoder(com.adaptris.core.AdaptrisMessageEncoder)
(such as for AS2) then this may
have no effect.
The default is PayloadStreamOutputParameter
.
public void setResponseBody(DataOutputParameter<InputStreamWithEncoding> responseBody)
Note that if you have configured an AdaptrisMessageEncoder
via
AdaptrisMessageWorkerImp.setEncoder(com.adaptris.core.AdaptrisMessageEncoder)
(such as for AS2) then this may
have no effect.
The default is PayloadStreamOutputParameter
.
@NonNull public @NonNull HttpAuthenticator getAuthenticator()
public void setAuthenticator(@NonNull @NonNull HttpAuthenticator authenticator)
public java.lang.Boolean getAlwaysSendPayload()
Only the TRACE method explicitly forbids an entity body; other methods are technically unrestricted. However, best practice suggests that entity bodies are only included for the POST/PUT/(PATCH) methods.
The default is fails if not otherwise specified
public void setAlwaysSendPayload(java.lang.Boolean alwaysSendPayload)
Only the TRACE method explicitly forbids an entity body; other methods are technically unrestricted. However, best practice suggests that entity bodies are only included for the POST/PUT/(PATCH) methods.
The default is fails if not otherwise specified
public TimeInterval getConnectTimeout()
public void setConnectTimeout(TimeInterval connectTimeout)
public TimeInterval getReadTimeout()
Note that any read timeout will be overridden by the timeout value passed in via the
{RequestReplyProducerImp.request(AdaptrisMessage, long)
method; if it is not the same as
60000
public void setReadTimeout(TimeInterval readTimeout)
Note that any read timeout will be overridden by the timeout value passed in via the
{RequestReplyProducerImp.request(AdaptrisMessage, long)
method; if it is not the same as
60000