Class AbstractHttpSender
- All Implemented Interfaces:
CanUseSharedResource<HttpSession>,FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IScopeProvider,ISender,ISenderWithParameters,IWithParameters,NameAware,HasKeystore,HasTruststore,ConfigurableLifecycle,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
CmisHttpSender,HttpSender,MsalClientAdapter,NetStorageSender
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
- Author:
- Niels Meijer
- Parameters
- Any parameters present are appended to the request (when method is
GETas request-parameters, when methodPOSTas body part) except theheadersParamslist, which are added as HTTP headers, and theurlParamheader
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.frankframework.http.AbstractHttpSession
AbstractHttpSession.OauthAuthenticationMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected ParameterListprotected URIprotected IParameterFields inherited from class org.frankframework.http.AbstractHttpSession
AUTHENTICATION_METHOD_KEY, logFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleanappendParameters(boolean parametersAppended, StringBuilder path, ParameterValueList parameters) voidConfigure this component.protected abstract MessageextractResult(HttpResponseHandler responseHandler, PipeLineSession session) Custom implementation to extract the response and format it to a String result.protected StringReturns the true name of the class and notXsltPipe$$EnhancerBySpringCGLIB$$563e6b5d.protected abstract org.apache.http.client.methods.HttpRequestBasegetMethod(URI uri, Message message, ParameterValueList parameters, PipeLineSession session) Custom implementation to create aHttpRequestobject.Used to validate the expected type so now unexpected ClassCastExceptions can occur.return the ParameterssendMessage(Message message, PipeLineSession session) Send a message to some destination (as configured in the Sender object).voidsetCharSet(String string) Charset of the request.voidsetContentType(String string) Content-Type (superset of mimetype + charset) of the request, forPOST,PUTandPATCHmethodsvoidsetHeadersParams(String headersParams) Comma separated list of parameter names which should be set as HTTP headersvoidThe HTTP Method used to execute the requestvoidsetParametersToSkipWhenEmpty(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.voidsetResultStatusCodeSessionKey(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.voidsetStyleSheetName(String stylesheetName) (Only used when xHtml=true) stylesheet to apply to the HTML responsevoidURL or base of URL to be used.voidsetUrlParam(String urlParam) Parameter that is used to obtain URL; overrides url-attribute.voidsetXhtml(boolean xHtml) Iftrue, the HTML response is transformed to XHTMLvoidstart()This method will be called to start the sender.voidstop()Stop/close the sender and deallocate resources.protected booleanvalidateResponseCode(int statusCode) Methods inherited from class org.frankframework.http.AbstractHttpSession
areCookiesDisabled, execute, getDomainAwareCredentials, getSSLConnectionSocketFactory, getURI, isRunning, setAllowSelfSignedCertificates, setAuthAlias, setAuthDomain, setAuthenticatedTokenRequest, setClientAlias, setClientId, setClientSecret, setConnectionIdleTimeout, setConnectionTimeToLive, setDisableCookies, setFollowRedirects, setHttpClient, setHttpContext, setIgnoreCertificateExpiredException, setIgnoreRedirects, setKeyManagerAlgorithm, setKeystore, setKeystoreAlias, setKeystoreAliasAuthAlias, setKeystoreAliasPassword, setKeystoreAuthAlias, setKeystorePassword, setKeystoreType, setMaxConnections, setMaxExecuteRetries, setOauthAuthenticationMethod, setPassword, setPrefillProxyAuthCache, setProtocol, setProxyAuthAlias, setProxyHost, setProxyPassword, setProxyPort, setProxyRealm, setProxyUsername, setSamlAssertionExpiry, setSamlAudience, setSamlIssuer, setSamlNameId, setScope, setStaleChecking, setStaleTimeout, setSupportedCipherSuites, setTimeout, setTokenEndpoint, setTokenExpiry, setTrustManagerAlgorithm, setTruststore, setTruststoreAuthAlias, setTruststorePassword, setTruststoreType, setUsername, setVerifyHostnameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.CanUseSharedResource
getSharedResource, setSharedResourceRefMethods inherited from interface org.frankframework.lifecycle.ConfigurableLifecycle
getPhase, isAutoStartup, isConfiguredMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.encryption.HasKeystore
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreTypeMethods inherited from interface org.frankframework.encryption.HasTruststore
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostnameMethods inherited from interface org.frankframework.core.ISender
isSynchronous, sendMessageOrThrowMethods inherited from interface org.frankframework.core.ISenderWithParameters
consumesSessionVariableMethods inherited from interface org.springframework.context.Lifecycle
isRunningMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Field Details
-
MESSAGE_ID_HEADER
- See Also:
-
CORRELATION_ID_HEADER
- See Also:
-
urlParameter
-
staticUri
-
requestOrBodyParamsSet
-
headerParamsSet
-
parametersToSkipWhenEmptySet
-
paramList
-
-
Constructor Details
-
AbstractHttpSender
public AbstractHttpSender()
-
-
Method Details
-
addParameter
- Specified by:
addParameterin interfaceIWithParameters
-
getParameterList
return the Parameters- Specified by:
getParameterListin interfaceIWithParameters
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classAbstractHttpSession- Throws:
ConfigurationException- in case it was not able to configure the component.
-
getObjectType
Description copied from interface:CanUseSharedResourceUsed to validate the expected type so now unexpected ClassCastExceptions can occur. May be NULL in which case this check will be skipped and the SharedResource will be returned regardless.- Specified by:
getObjectTypein interfaceCanUseSharedResource<HttpSession>
-
start
public void start()Description copied from interface:ISenderThis method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in thesendMessage()method.- Specified by:
startin interfaceConfigurableLifecycle- Specified by:
startin interfaceISender- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Overrides:
startin classAbstractHttpSession
-
stop
public void stop()Description copied from interface:ISenderStop/close the sender and deallocate resources.- Specified by:
stopin interfaceISender- Specified by:
stopin interfaceorg.springframework.context.Lifecycle- Overrides:
stopin classAbstractHttpSession
-
appendParameters
protected boolean appendParameters(boolean parametersAppended, StringBuilder path, ParameterValueList parameters) throws SenderException - Throws:
SenderException
-
getLogPrefix
Returns the true name of the class and notXsltPipe$$EnhancerBySpringCGLIB$$563e6b5d.ClassUtils.nameOf(Object)makes sure the original class will be used.- Returns:
- className + name of the ISender
-
getMethod
protected abstract org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, @Nonnull ParameterValueList parameters, PipeLineSession session) throws SenderException Custom implementation to create aHttpRequestobject.- Parameters:
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 set- Returns:
- a
HttpRequestobject - Throws:
SenderException
-
extractResult
protected abstract Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException Custom implementation to extract the response and format it to a String result.
It is important that theresponsewill be read or will beclosed.- Parameters:
responseHandler-HttpResponseHandlerthat contains the response informationsession-PipeLineSessionwhich may be null- Returns:
- a string that will be passed to the pipeline
- Throws:
SenderExceptionIOException
-
validateResponseCode
protected boolean validateResponseCode(int statusCode) -
sendMessage
@Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException, TimeoutException Description copied from interface:ISenderSend a message to some destination (as configured in the Sender object). This method may only be called after theconfigure()method is called.The following table shows the difference between synchronous and a-synchronous senders:
synchronous a-synchronous ISender.isSynchronous()returnstruefalsereturn value of sendMessage()isthe 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.- Specified by:
sendMessagein interfaceISender- Throws:
SenderExceptionTimeoutException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
getCredentials
-
getTokenEndpoint
-
getOauthAuthenticationMethod
-
setUrl
URL or base of URL to be used. Expects all parts of the URL to already be encoded. -
setUrlParam
Parameter that is used to obtain URL; overrides url-attribute.- Default value
- url
-
setMethodType
The HTTP Method used to execute the request- Default value
GET
-
setContentType
Content-Type (superset of mimetype + charset) of the request, forPOST,PUTandPATCHmethods- Default value
- text/html, when postType=
RAW
-
setCharSet
Charset of the request. Typically only used onPUTandPOSTrequests.- Default value
- UTF-8
-
setHeadersParams
Comma separated list of parameter names which should be set as HTTP headers -
setParametersToSkipWhenEmpty
Comma separated list of parameter names that should not be added as request or body parameter, or as HTTP header, if they are empty. Set to '*' for this behaviour for all parameters -
setXhtml
public void setXhtml(boolean xHtml) Iftrue, the HTML response is transformed to XHTML- Default value
- false
-
setStyleSheetName
(Only used when xHtml=true) stylesheet to apply to the HTML response -
setResultStatusCodeSessionKey
If set, the status code of the HTTP response is put in the specified sessionKey and the (error or okay) response message is returned. Setting this property has a side effect. If a 4xx or 5xx result code is returned and if the pipeline does not implement the specific forward, pipeline-global forward or pipeline-exit for the returned HTTP result code, then the success forward is followed instead of the exception forward.
-