Package org.frankframework.http
Class HttpSender
java.lang.Object
org.frankframework.http.AbstractHttpSession
org.frankframework.http.AbstractHttpSender
org.frankframework.http.HttpSender
- All Implemented Interfaces:
AdapterAware
,CanUseSharedResource<HttpSession>
,HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,ISender
,ISenderWithParameters
,IWithParameters
,HasKeystore
,HasTruststore
,ConfigurableLifecycle
,HasStatistics
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
MultipartHttpSender
,RestSender
,WebServiceSender
Sender for the HTTP protocol using
HttpMethod
. By default, any response code outside the 2xx or 3xx range
is considered an error and the exception
forward of the SenderPipe is followed if present and if there
is no forward for the specific HTTP status code. Forwards for specific HTTP codes (e.g. "200", "201", ...)
are returned by this sender, so they are available to the SenderPipe.
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
- Since:
- 7.0
- Version:
- 2.0
- Author:
- Niels Meijer
-
Nested Class Summary
Nested classes/interfaces inherited from class org.frankframework.http.AbstractHttpSender
AbstractHttpSender.HttpMethod
-
Field Summary
Fields inherited from class org.frankframework.http.AbstractHttpSender
CORRELATION_ID_HEADER, headerParamsSet, MESSAGE_ID_HEADER, parametersToSkipWhenEmptySet, paramList, requestOrBodyParamsSet, staticUri, urlParameter
Fields inherited from class org.frankframework.http.AbstractHttpSession
log
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Configure this component.protected org.apache.http.entity.mime.FormBodyPart
elementToFormBodyPart
(Element element, PipeLineSession session) protected Message
extractResult
(HttpResponseHandler responseHandler, PipeLineSession session) Custom implementation to extract the response and format it to a String result.protected org.apache.http.client.methods.HttpRequestBase
getMethod
(URI uri, Message message, ParameterValueList parameters) Returns HttpRequestBase, with (optional) RAW or as BINAIRY contentprotected org.apache.http.client.methods.HttpRequestBase
getMethod
(URI url, Message message, ParameterValueList parameters, PipeLineSession session) Custom implementation to create aHttpRequest
object.getResponseBody
(HttpResponseHandler responseHandler) boolean
boolean
void
setEncodeMessages
(boolean b) Specifies whether messages will encoded, e.g. spaces will be replaced by '+' etc.void
setFirstBodyPartName
(String firstBodyPartName) (Only used whenmethodType=POST
andpostType=URLENCODED
,FORM-DATA
orMTOM
) Prepends a new BodyPart using the specified name and uses the input of the Sender as contentvoid
setMtomContentTransferEncoding
(String mtomContentTransferEncoding) void
setMultipartXmlSessionKey
(String multipartXmlSessionKey) If set andmethodType=POST
andparamsInUrl=false
, a multipart/form-data entity is created instead of a request body.void
setParamsInUrl
(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.void
IfmethodType
=POST
,PUT
orPATCH
, the type of post requestvoid
Iftrue
, the input will be added to the URL formethodType=GET
, or formethodType=POST
,PUT
orPATCH
ifpostType=RAW
.Methods inherited from class org.frankframework.http.AbstractHttpSender
addParameter, appendParameters, getCharSet, getContentType, getDomain, getFullContentType, getHeadersParams, getHttpMethod, getLogPrefix, getObjectType, getParameterList, getParametersToSkipWhenEmpty, getPhysicalDestinationName, getResultStatusCodeSessionKey, getStyleSheetName, getUrl, getUrlParam, isXhtml, sendMessage, setCertificate, setCertificateAuthAlias, setCertificatePassword, setCertificateType, setCharSet, setContentType, setHeadersParams, setMethodType, setParametersToSkipWhenEmpty, setResultStatusCodeSessionKey, setSharedResourceRef, setStyleSheetName, setUrl, setUrlParam, setXhtml, start, stop, validateResponseCode
Methods inherited from class org.frankframework.http.AbstractHttpSession
areCookiesDisabled, execute, getAdapter, getApplicationContext, getAuthAlias, getAuthDomain, getClientAuthAlias, getClientId, getClientSecret, getConfigurationClassLoader, getConnectionIdleTimeout, getConnectionTimeToLive, getDefaultHttpClientContext, getHttpClient, getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreType, getMaxConnections, getMaxExecuteRetries, getName, getPassword, getProxyAuthAlias, getProxyHost, getProxyPassword, getProxyPort, getProxyRealm, getProxyUsername, getScope, getSSLConnectionSocketFactory, getStaleTimeout, getTimeout, getTokenEndpoint, getTokenExpiry, getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, getURI, getUsername, isAllowSelfSignedCertificates, isAuthenticatedTokenRequest, isFollowRedirects, isIgnoreCertificateExpiredException, isIgnoreRedirects, isPrefillProxyAuthCache, isRunning, isStaleChecking, isVerifyHostname, setAdapter, setAllowSelfSignedCertificates, setApplicationContext, setAuthAlias, setAuthDomain, setAuthenticatedTokenRequest, setClientAlias, setClientId, setClientSecret, setConfigurationMetrics, setConnectionIdleTimeout, setConnectionTimeToLive, setDisableCookies, setFollowRedirects, setHttpClient, setHttpContext, setIgnoreCertificateExpiredException, setIgnoreRedirects, setKeyManagerAlgorithm, setKeystore, setKeystoreAlias, setKeystoreAliasAuthAlias, setKeystoreAliasPassword, setKeystoreAuthAlias, setKeystorePassword, setKeystoreType, setMaxConnections, setMaxExecuteRetries, setName, setPassword, setPrefillProxyAuthCache, setProtocol, setProxyAuthAlias, setProxyHost, setProxyPassword, setProxyPort, setProxyRealm, setProxyUsername, setScope, setStaleChecking, setStaleTimeout, setSupportedCipherSuites, setTimeout, setTokenEndpoint, setTokenExpiry, setTrustManagerAlgorithm, setTruststore, setTruststoreAuthAlias, setTruststorePassword, setTruststoreType, setUsername, setVerifyHostname
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.CanUseSharedResource
getSharedResource
Methods inherited from interface org.frankframework.lifecycle.ConfigurableLifecycle
getPhase, isAutoStartup
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.ISender
isSynchronous, sendMessageOrThrow
Methods inherited from interface org.frankframework.core.ISenderWithParameters
consumesSessionVariable
Methods inherited from interface org.springframework.context.Lifecycle
isRunning
Methods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
HttpSender
public HttpSender()
-
-
Method Details
-
configure
Description copied from interface:ConfigurableLifecycle
Configure this component.In the case of a container, this will propagate the start signal to all components that apply.
- Specified by:
configure
in interfaceConfigurableLifecycle
- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceISender
- Overrides:
configure
in classAbstractHttpSender
- Throws:
ConfigurationException
- in case it was not able to configure the component.
-
getMethod
protected org.apache.http.client.methods.HttpRequestBase getMethod(URI url, Message message, ParameterValueList parameters, PipeLineSession session) throws SenderException Description copied from class:AbstractHttpSender
Custom implementation to create aHttpRequest
object.- Specified by:
getMethod
in classAbstractHttpSender
- Parameters:
url
- 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 set- Returns:
- a
HttpRequest
object - Throws:
SenderException
-
getMethod
protected org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, ParameterValueList parameters) throws SenderException Returns HttpRequestBase, with (optional) RAW or as BINAIRY content- Throws:
SenderException
-
elementToFormBodyPart
protected org.apache.http.entity.mime.FormBodyPart elementToFormBodyPart(Element element, PipeLineSession session) throws IOException - Throws:
IOException
-
extractResult
protected Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException Description copied from class:AbstractHttpSender
Custom implementation to extract the response and format it to a String result.
It is important that theresponse
will be read or will beclosed
.- Specified by:
extractResult
in classAbstractHttpSender
- Parameters:
responseHandler
-HttpResponseHandler
that contains the response informationsession
-PipeLineSession
which may be null- Returns:
- a string that will be passed to the pipeline
- Throws:
SenderException
IOException
-
getResponseBody
-
setPostType
IfmethodType
=POST
,PUT
orPATCH
, the type of post request- Default value
- RAW
-
setParamsInUrl
Deprecated, for removal: This API element is subject to removal in a future version.If false andmethodType
=POST
, request parameters are put in the request body instead of in the url- Default value
- true
-
setFirstBodyPartName
(Only used whenmethodType=POST
andpostType=URLENCODED
,FORM-DATA
orMTOM
) Prepends a new BodyPart using the specified name and uses the input of the Sender as content -
setMultipartXmlSessionKey
If set andmethodType=POST
andparamsInUrl=false
, a multipart/form-data entity is created instead of a request body. For each part element in the session key a part in the multipart entity is created. Part elements can contain the following attributes:- name: optional, used as 'filename' in Content-Disposition
- sessionKey: mandatory, refers to contents of part
- mimeType: optional MIME type
-
setMtomContentTransferEncoding
-
setEncodeMessages
public void setEncodeMessages(boolean b) Specifies whether messages will encoded, e.g. spaces will be replaced by '+' etc.- Default value
- false
-
setTreatInputMessageAsParameters
Iftrue
, the input will be added to the URL formethodType=GET
, or formethodType=POST
,PUT
orPATCH
ifpostType=RAW
. This used to be the default behaviour in framework version 7.7 and earlier- Default value
- for methodType=
GET
:false
,
for methodTypesPOST
,PUT
,PATCH
:true
-
isParamsInUrl
public boolean isParamsInUrl() -
getFirstBodyPartName
-
getMultipartXmlSessionKey
-
getMtomContentTransferEncoding
-
isEncodeMessages
public boolean isEncodeMessages() -
getTreatInputMessageAsParameters
-
getPostType
-