@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
CONFIRMATION_ID_KEY
Constructor and Description |
---|
StandardHttpProducer() |
StandardHttpProducer(ProduceDestination d) |
Modifier and Type | Method and Description |
---|---|
protected AdaptrisMessage |
doRequest(AdaptrisMessage msg,
ProduceDestination destination,
long timeout)
Actually do the request.
|
java.lang.Boolean |
getAlwaysSendPayload() |
HttpAuthenticator |
getAuthenticator() |
TimeInterval |
getConnectTimeout() |
TimeInterval |
getReadTimeout() |
DataInputParameter<java.io.InputStream> |
getRequestBody() |
DataOutputParameter<InputStreamWithEncoding> |
getResponseBody() |
void |
prepare()
Prepare for initialisation.
|
void |
produce(AdaptrisMessage msg,
ProduceDestination dest)
Produce the
AdaptrisMessage to the supplied ProduceDestination , over-riding any configured destinations. |
void |
setAlwaysSendPayload(java.lang.Boolean b)
Specify whether or not to always attempt to send the payload as the entity body.
|
void |
setAuthenticator(HttpAuthenticator authenticator)
Set the authentication method to use for the HTTP request
|
void |
setConnectTimeout(TimeInterval t)
Set the connect timeout.
|
void |
setReadTimeout(TimeInterval t)
Set the read timeout.
|
void |
setRequestBody(DataInputParameter<java.io.InputStream> input)
Set where the HTTP Request body is going to come from.
|
void |
setResponseBody(DataOutputParameter<InputStreamWithEncoding> output)
Set where the HTTP Response Body will be written to.
|
close, defaultTimeout, getAllowRedirect, getContentTypeProvider, getIgnoreServerResponseCode, getMethod, getMethodProvider, getRequestHeaderProvider, getResponseHeaderHandler, init, logHeaders, setAllowRedirect, setContentTypeProvider, setIgnoreServerResponseCode, setMethodProvider, setRequestHeaderProvider, setResponseHeaderHandler, start, stop
getIgnoreReplyMetadata, produce, request, request, request, request, setIgnoreReplyMetadata, shouldIgnoreReplyMetadata
getDestination, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
public StandardHttpProducer()
public StandardHttpProducer(ProduceDestination d)
public void produce(AdaptrisMessage msg, ProduceDestination dest) throws ProduceException
AdaptrisMessageSender
AdaptrisMessage
to the supplied ProduceDestination
, over-riding any configured destinations.produce
in interface AdaptrisMessageSender
produce
in class HttpProducer<java.net.HttpURLConnection,java.net.HttpURLConnection>
msg
- the AdaptrisMessage
to producedest
- the ProduceDestination
to produce toProduceException
- wrapping any underlying ExceptionsAdaptrisMessageSender.produce(AdaptrisMessage, ProduceDestination)
protected AdaptrisMessage doRequest(AdaptrisMessage msg, ProduceDestination destination, long timeout) throws ProduceException
RequestReplyProducerImp
doRequest
in class RequestReplyProducerImp
ProduceException
#request(AdaptrisMessage,
ProduceDestination, long)
public DataInputParameter<java.io.InputStream> getRequestBody()
public void setRequestBody(DataInputParameter<java.io.InputStream> input)
input
- the input; default is PayloadStreamInputParameter
which is the only implementation currently.public DataOutputParameter<InputStreamWithEncoding> getResponseBody()
public void setResponseBody(DataOutputParameter<InputStreamWithEncoding> output)
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.
output
- the output; default is PayloadStreamOutputParameter
.public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public HttpAuthenticator getAuthenticator()
public void setAuthenticator(HttpAuthenticator authenticator)
public java.lang.Boolean getAlwaysSendPayload()
public void setAlwaysSendPayload(java.lang.Boolean b)
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.
b
- set this to true to always attempt to send a body (apart from TRACE), default false.public TimeInterval getConnectTimeout()
public void setConnectTimeout(TimeInterval t)
t
- the timeout (will be used for URLConnection.setConnectTimeout(int)
)public TimeInterval getReadTimeout()
public void setReadTimeout(TimeInterval t)
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
t
- the timeout (will be used for URLConnection.setReadTimeout(int)
)