public class HttpSender extends HttpSenderBase
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_valueNote: When used as MTOM sender and MTOM receiver doesn't support Content-Transfer-Encoding "base64", messages without line feeds will give an error. This can be fixed by setting the Content-Transfer-Encoding in the MTOM sender.
Modifier and Type | Class and Description |
---|---|
static class |
HttpSender.PostType |
HttpSenderBase.HttpMethod
CORRELATION_ID_HEADER, headerParamsSet, MESSAGE_ID_HEADER, parametersToSkipWhenEmptySet, requestOrBodyParamsSet, staticUri, urlParameter
parameterNamesMustBeUnique, paramList
log
Constructor and Description |
---|
HttpSender() |
Modifier and Type | Method and Description |
---|---|
void |
configure()
configure() is called once at startup of the framework in the configure method of the owner of this sender. |
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 content
|
protected org.apache.http.client.methods.HttpRequestBase |
getMethod(URI url,
Message message,
ParameterValueList parameters,
PipeLineSession session)
Custom implementation to create a
HttpRequest object. |
Message |
getResponseBody(HttpResponseHandler responseHandler) |
Message |
getResponseBodyAsBase64(InputStream is) |
static Message |
handleMultipartResponse(String mimeType,
InputStream inputStream,
PipeLineSession session)
return the first part as Message and put the other parts as InputStream in the PipeLineSession
|
void |
setBase64(boolean b)
Deprecated.
|
void |
setEncodeMessages(boolean b)
Specifies whether messages will encoded, e.g.
|
void |
setFirstBodyPartName(String firstBodyPartName)
(Only used when
methodType =POST and postType =URLENCODED , FORM-DATA or MTOM ) Prepends a new BodyPart using the specified name and uses the input of the Sender as content |
void |
setInputMessageParam(String inputMessageParam)
Deprecated.
|
void |
setMtomContentTransferEncoding(String mtomContentTransferEncoding) |
void |
setMtomEnabled(boolean b)
Deprecated.
|
void |
setMultipart(boolean b)
Deprecated.
|
void |
setMultipartResponse(Boolean b)
Deprecated.
|
void |
setMultipartXmlSessionKey(String multipartXmlSessionKey)
If set and
methodType =POST and paramsInUrl =false , a multipart/form-data entity is created instead of a request body. |
void |
setParamsInUrl(boolean b)
Deprecated.
|
void |
setPostType(HttpSender.PostType type)
If
methodType =POST , PUT or PATCH , the type of post request |
void |
setStoreResultAsByteArrayInSessionKey(String storeResultAsByteArrayInSessionKey)
Deprecated.
|
void |
setStoreResultAsStreamInSessionKey(String storeResultAsStreamInSessionKey)
Deprecated.
|
void |
setStreamResultToFileNameSessionKey(String string)
Deprecated.
|
void |
setStreamResultToServlet(boolean b)
If set, the result is streamed to the HhttpServletResponse object of the RestServiceDispatcher (instead of passed as a string)
|
void |
setTreatInputMessageAsParameters(Boolean b)
If
true , the input will be added to the URL for methodType =GET , or for methodType =POST , PUT or PATCH if postType =RAW . |
static void |
streamResponseBody(InputStream is,
String contentType,
String contentDisposition,
javax.servlet.http.HttpServletResponse response,
org.apache.logging.log4j.Logger log,
String logPrefix) |
static void |
streamResponseBody(InputStream is,
String contentType,
String contentDisposition,
javax.servlet.http.HttpServletResponse response,
org.apache.logging.log4j.Logger log,
String logPrefix,
String redirectLocation) |
appendParameters, areCookiesDisabled, close, getPhysicalDestinationName, getPort, getSSLConnectionSocketFactory, getURI, open, prefillProxyAuthCache, sendMessage, setAllowSelfSignedCertificates, setAuthAlias, setAuthDomain, setAuthenticatedTokenRequest, setCertificate, setCertificateAuthAlias, setCertificatePassword, setCertificateType, setCharSet, setClientAlias, setClientId, setClientSecret, setConnectionIdleTimeout, setConnectionTimeToLive, setContentType, setDisableCookies, setFollowRedirects, setHeadersParams, setIgnoreCertificateExpiredException, setIgnoreRedirects, setKeyManagerAlgorithm, setKeystore, setKeystoreAlias, setKeystoreAliasAuthAlias, setKeystoreAliasPassword, setKeystoreAuthAlias, setKeystorePassword, setKeystoreType, setMaxConnections, setMaxExecuteRetries, setMethodType, setParametersToSkipWhenEmpty, setPassword, setProtocol, setProxyAuthAlias, setProxyHost, setProxyPassword, setProxyPort, setProxyRealm, setProxyUsername, setProxyUserName, setResultStatusCodeSessionKey, setScope, setStaleChecking, setStaleTimeout, setStyleSheetName, setTimeout, setTokenEndpoint, setTokenExpiry, setTrustManagerAlgorithm, setTruststore, setTruststoreAuthAlias, setTruststorePassword, setTruststoreType, setUrl, setUrlParam, setUsername, setUserName, setVerifyHostname, setXhtml, validateResponseCode
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
createBean, getLogPrefix, getName, isSynchronous, setApplicationContext, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDomain
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreType
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostname
isSynchronous, sendMessageOrThrow
getName, setName
public void configure() throws ConfigurationException
ISender
configure()
is called once at startup of the framework in the configure method of the owner of this sender.
Purpose of this method is to check whether the static configuration of the sender is correct.
As much as possible class-instantiating should take place in the configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface ISender
configure
in class HttpSenderBase
ConfigurationException
protected org.apache.http.client.methods.HttpRequestBase getMethod(URI url, Message message, ParameterValueList parameters, PipeLineSession session) throws SenderException
HttpSenderBase
HttpRequest
object.getMethod
in class HttpSenderBase
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 setHttpRequest
objectSenderException
protected org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, ParameterValueList parameters) throws SenderException
SenderException
protected org.apache.http.entity.mime.FormBodyPart elementToFormBodyPart(Element element, PipeLineSession session) throws IOException
IOException
protected Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException
HttpSenderBase
response
will be read or will be closed
.extractResult
in class HttpSenderBase
responseHandler
- HttpResponseHandler
that contains the response informationsession
- PipeLineSession
which may be nullSenderException
IOException
public Message getResponseBody(HttpResponseHandler responseHandler)
public Message getResponseBodyAsBase64(InputStream is)
public static Message handleMultipartResponse(String mimeType, InputStream inputStream, PipeLineSession session) throws IOException
IOException
public static void streamResponseBody(InputStream is, String contentType, String contentDisposition, javax.servlet.http.HttpServletResponse response, org.apache.logging.log4j.Logger log, String logPrefix) throws IOException
IOException
public static void streamResponseBody(InputStream is, String contentType, String contentDisposition, javax.servlet.http.HttpServletResponse response, org.apache.logging.log4j.Logger log, String logPrefix, String redirectLocation) throws IOException
IOException
public void setPostType(HttpSender.PostType type)
methodType
=POST
, PUT
or PATCH
, the type of post request@Deprecated public void setParamsInUrl(boolean b)
methodType
=POST
, request parameters are put in the request body instead of in the url@Deprecated @ConfigurationWarning(value="Use the firstBodyPartName attribute instead") public void setInputMessageParam(String inputMessageParam)
public void setFirstBodyPartName(String firstBodyPartName)
methodType
=POST
and postType
=URLENCODED
, FORM-DATA
or MTOM
) Prepends a new BodyPart using the specified name and uses the input of the Sender as content@Deprecated @ConfigurationWarning(value="no longer required to store the result as a file in the PipeLineSession, the sender can return binary data") public void setStreamResultToFileNameSessionKey(String string)
@Deprecated @ConfigurationWarning(value="no longer required to store the result as a stream in the PipeLineSession, the sender can return binary data") public void setStoreResultAsStreamInSessionKey(String storeResultAsStreamInSessionKey)
@Deprecated @ConfigurationWarning(value="no longer required to store the result as a byte array in the PipeLineSession, the sender can return binary data") public void setStoreResultAsByteArrayInSessionKey(String storeResultAsByteArrayInSessionKey)
@Deprecated @ConfigurationWarning(value="use Base64Pipe instead") public void setBase64(boolean b)
public void setStreamResultToServlet(boolean b)
@Deprecated @ConfigurationWarning(value="multipart has been replaced by postType=\'formdata\'") public void setMultipart(boolean b)
@Deprecated @ConfigurationWarning(value="Unless set explicitly multipart response will be detected automatically") public void setMultipartResponse(Boolean b)
public void setMultipartXmlSessionKey(String multipartXmlSessionKey)
methodType
=POST
and paramsInUrl
=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:
@Deprecated @ConfigurationWarning(value="mtomEnabled has been replaced by postType=\'mtom\'") public void setMtomEnabled(boolean b)
public void setMtomContentTransferEncoding(String mtomContentTransferEncoding)
public void setEncodeMessages(boolean b)
public void setTreatInputMessageAsParameters(Boolean b)
true
, the input will be added to the URL for methodType
=GET
, or for methodType
=POST
, PUT
or PATCH
if postType
=RAW
. This used to be the default behaviour in framework version 7.7 and earlierGET
: false
,POST
, PUT
, PATCH
: true
Copyright © 2023 Frank!Framework. All rights reserved.