public abstract class HttpSenderBase extends HttpSessionBase implements HasPhysicalDestination, ISenderWithParameters, CanUseSharedResource<org.apache.http.impl.client.CloseableHttpClient>
Expected message format:
GET methods expect a message looking like this
param_name=param_value&another_param_name=another_param_value
POST AND PUT methods expect a message similar as GET, or looking like this
param_name=param_value another_param_name=another_param_value
GET
as request-parameters, when method POST
as body part) except the headersParams
list, which are added as HTTP headers, and the urlParam
headerModifier and Type | Class and Description |
---|---|
static class |
HttpSenderBase.HttpMethod |
Modifier and Type | Field and Description |
---|---|
static String |
CORRELATION_ID_HEADER |
protected Set<String> |
headerParamsSet |
static String |
MESSAGE_ID_HEADER |
protected Set<String> |
parametersToSkipWhenEmptySet |
protected ParameterList |
paramList |
protected Set<String> |
requestOrBodyParamsSet |
protected URI |
staticUri |
protected Parameter |
urlParameter |
log
Constructor and Description |
---|
HttpSenderBase() |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(Parameter p) |
protected boolean |
appendParameters(boolean parametersAppended,
StringBuilder path,
ParameterValueList parameters) |
void |
close()
Stop/close the sender and deallocate resources.
|
void |
configure()
Configure this component.
|
protected abstract Message |
extractResult(HttpResponseHandler responseHandler,
PipeLineSession session)
Custom implementation to extract the response and format it to a String result.
|
protected String |
getLogPrefix()
Returns the true name of the class and not
XsltPipe$$EnhancerBySpringCGLIB$$563e6b5d . |
protected abstract org.apache.http.client.methods.HttpRequestBase |
getMethod(URI uri,
Message message,
ParameterValueList parameters,
PipeLineSession session)
Custom implementation to create a
HttpRequest object. |
Class<org.apache.http.impl.client.CloseableHttpClient> |
getObjectType()
Used to validate the expected type so now unexpected ClassCastExceptions can occur.
|
ParameterList |
getParameterList()
return the Parameters
|
String |
getPhysicalDestinationName() |
void |
open()
This method will be called to start the sender.
|
SenderResult |
sendMessage(Message message,
PipeLineSession session)
Send a message to some destination (as configured in the Sender object).
|
void |
setCertificate(String string)
Deprecated.
|
void |
setCertificateAuthAlias(String string)
Deprecated.
|
void |
setCertificatePassword(String string)
Deprecated.
|
void |
setCertificateType(KeystoreType value)
Deprecated.
|
void |
setCharSet(String string)
Charset of the request.
|
void |
setContentType(String string)
Content-Type (superset of mimetype + charset) of the request, for
POST , PUT and PATCH methods |
void |
setHeadersParams(String headersParams)
Comma separated list of parameter names which should be set as HTTP headers
|
void |
setMethodType(HttpSenderBase.HttpMethod method)
The HTTP Method used to execute the request
|
void |
setParametersToSkipWhenEmpty(String parametersToSkipWhenEmpty)
Comma separated list of parameter names that should not be added as request or body parameter, or as HTTP header, if they are empty.
|
void |
setProxyUserName(String string)
Deprecated.
|
void |
setResultStatusCodeSessionKey(String resultStatusCodeSessionKey)
If set, the status code of the HTTP response is put in the specified sessionKey and the (error or okay) response message is returned.
|
void |
setStyleSheetName(String stylesheetName)
(Only used when xHtml=
true ) stylesheet to apply to the HTML response |
void |
setUrl(String string)
URL or base of URL to be used
|
void |
setUrlParam(String urlParam)
Parameter that is used to obtain URL; overrides url-attribute.
|
void |
setUserName(String username)
Deprecated.
|
void |
setXhtml(boolean xHtml)
If
true , the HTML response is transformed to XHTML |
void |
start() |
protected boolean |
validateResponseCode(int statusCode) |
areCookiesDisabled, buildHttpClient, configureConnectionManager, execute, getSSLConnectionSocketFactory, getURI, isRunning, preAuthenticate, setAllowSelfSignedCertificates, setAuthAlias, setAuthDomain, setAuthenticatedTokenRequest, setClientAlias, setClientId, setClientSecret, setConnectionIdleTimeout, setConnectionTimeToLive, setDisableCookies, setFollowRedirects, setHttpClient, setIgnoreCertificateExpiredException, setIgnoreRedirects, setKeyManagerAlgorithm, setKeystore, setKeystoreAlias, setKeystoreAliasAuthAlias, setKeystoreAliasPassword, setKeystoreAuthAlias, setKeystorePassword, setKeystoreType, setMaxConnections, setMaxExecuteRetries, setPassword, setPrefillProxyAuthCache, setProtocol, setProxyAuthAlias, setProxyHost, setProxyPassword, setProxyPort, setProxyRealm, setProxyUsername, setScope, setStaleChecking, setStaleTimeout, setTimeout, setTokenEndpoint, setTokenExpiry, setTrustManagerAlgorithm, setTruststore, setTruststoreAuthAlias, setTruststorePassword, setTruststoreType, setUsername, setVerifyHostname, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDomain
consumesSessionVariable
isSynchronous, sendMessageOrThrow
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getSharedResource, setSharedResourceRef
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreType
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostname
public static final String MESSAGE_ID_HEADER
public static final String CORRELATION_ID_HEADER
protected Parameter urlParameter
protected URI staticUri
protected ParameterList paramList
public void addParameter(Parameter p)
addParameter
in interface IWithParameters
public ParameterList getParameterList()
getParameterList
in interface IWithParameters
public void configure() throws ConfigurationException
ConfigurableLifecycle
In the case of a container, this will propagate the start signal to all components that apply.
configure
in interface IConfigurable
configure
in interface ISender
configure
in interface ConfigurableLifecycle
configure
in class HttpSessionBase
ConfigurationException
- in case it was not able to configure the component.public void open() throws SenderException
ISender
sendMessage()
method.open
in interface ISender
SenderException
public Class<org.apache.http.impl.client.CloseableHttpClient> getObjectType()
CanUseSharedResource
getObjectType
in interface CanUseSharedResource<org.apache.http.impl.client.CloseableHttpClient>
public void start()
start
in interface org.springframework.context.Lifecycle
start
in class HttpSessionBase
public void close()
ISender
protected boolean appendParameters(boolean parametersAppended, StringBuilder path, ParameterValueList parameters) throws SenderException
SenderException
protected String getLogPrefix()
XsltPipe$$EnhancerBySpringCGLIB$$563e6b5d
.
ClassUtils.nameOf(Object)
makes sure the original class will be used.protected abstract org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, ParameterValueList parameters, PipeLineSession session) throws SenderException
HttpRequest
object.uri
- endpoint to send the message tomessage
- to be sentparameters
- ParameterValueList that contains all the senders parameterssession
- PipeLineSession to retrieve or store data from, or NULL when not setHttpRequest
objectSenderException
protected abstract Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException
response
will be read or will be closed
.responseHandler
- HttpResponseHandler
that contains the response informationsession
- PipeLineSession
which may be nullSenderException
IOException
protected boolean validateResponseCode(int statusCode)
public SenderResult sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException
ISender
configure()
method is called.
The following table shows the difference between synchronous and a-synchronous senders:
synchronous | a-synchronous | |
---|---|---|
ISender.isSynchronous() returns | true | false |
return value of sendMessage() is | the reply-message | the messageId of the message sent |
the correlationID specified with sendMessage() | may be ignored | is sent with the message |
a {link TimeOutException} | may be thrown if a timeout occurs waiting for a reply | should not be expected |
Multiple objects may try to call this method at the same time, from different threads.
Implementations of this method should therefore be thread-safe, or synchronized
.
sendMessage
in interface ISender
SenderException
TimeoutException
public String getPhysicalDestinationName()
getPhysicalDestinationName
in interface HasPhysicalDestination
public void setUrl(String string)
public void setUrlParam(String urlParam)
public void setMethodType(HttpSenderBase.HttpMethod method)
GET
public void setContentType(String string)
POST
, PUT
and PATCH
methodsRAW
public void setCharSet(String string)
PUT
and POST
requests.@Deprecated @ConfigurationWarning(value="Please use attribute username instead") public void setUserName(String username)
@Deprecated @ConfigurationWarning(value="Please use \"proxyUsername\" instead") public void setProxyUserName(String string)
@Deprecated @ConfigurationWarning(value="Please use attribute keystore instead") public void setCertificate(String string)
@Deprecated @ConfigurationWarning(value="has been replaced with keystoreType") public void setCertificateType(KeystoreType value)
@Deprecated @ConfigurationWarning(value="Please use attribute keystoreAuthAlias instead") public void setCertificateAuthAlias(String string)
@Deprecated @ConfigurationWarning(value="Please use attribute keystorePassword instead") public void setCertificatePassword(String string)
public void setHeadersParams(String headersParams)
public void setParametersToSkipWhenEmpty(String parametersToSkipWhenEmpty)
public void setXhtml(boolean xHtml)
true
, the HTML response is transformed to XHTMLpublic void setStyleSheetName(String stylesheetName)
true
) stylesheet to apply to the HTML responsepublic void setResultStatusCodeSessionKey(String resultStatusCodeSessionKey)
Copyright © 2023 Frank!Framework. All rights reserved.