Package com.ibm.di.connector.maximo.util
Class HttpClient
- java.lang.Object
-
- com.ibm.di.connector.maximo.util.HttpClient
-
public final class HttpClient extends java.lang.ObjectHTTP client used for request/response communication.This HTTP client will try to communicate with one of the HTTP servers provided by target URL list.
- Since:
- 7.1
-
-
Constructor Summary
Constructors Constructor Description HttpClient(Log log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamgetAsInputStream()Requests the resource specified by the target URL list as an input stream.java.util.List<java.lang.String>getTargetUrlList()java.lang.Stringpost(java.lang.String msg)Requests the resource specified by the target URL list.voidsetAuthenticationRequired(boolean isRequired)Indicates if the authentication header containing the user's credentials should be sent.voidsetPassword(java.lang.String pass)Defines the user's password.voidsetTargetUrlList(java.util.List<java.lang.String> targetUrlList)Defines the list of HTTP server's target URLs to which resources will be requested.voidsetTimeout(int timeout)Defines the timeout, in milliseconds.voidsetUserId(java.lang.String userId)Defines the user's identification.voidsetXmlCharValidationEnabled(boolean enabled)Defines if the response message should be validated against invalid XML characters.java.lang.StringtoString()
-
-
-
Constructor Detail
-
HttpClient
public HttpClient(Log log)
-
-
Method Detail
-
getAsInputStream
public java.io.InputStream getAsInputStream() throws MxConnConfigException, MxConnIOExceptionRequests the resource specified by the target URL list as an input stream.- Returns:
- input stream to the requested resource
- Throws:
MxConnConfigException- if no target URL list is definedMxConnIOException- if any communication problem occurs- Since:
- 1.4.0
- See Also:
setTargetUrlList(List),setAuthenticationRequired(boolean),setTimeout(int)
-
post
public java.lang.String post(java.lang.String msg) throws MxConnConfigException, MxConnIOExceptionRequests the resource specified by the target URL list. If no message is provided, the request method used is GET, otherwise the request method is POST.- Parameters:
msg- message to be posted- Returns:
- response returned
- Throws:
MxConnConfigException- if no target URL list is definedMxConnIOException- if any communication problem occurs- See Also:
setTargetUrlList(List),setAuthenticationRequired(boolean),setTimeout(int)
-
setAuthenticationRequired
public void setAuthenticationRequired(boolean isRequired)
Indicates if the authentication header containing the user's credentials should be sent.- Parameters:
isRequired-trueif the authentication header should be sent, otherwisefalse- See Also:
setUserId(String),setPassword(String)
-
setPassword
public void setPassword(java.lang.String pass)
Defines the user's password.- Parameters:
pass- user's password
-
setTargetUrlList
public void setTargetUrlList(java.util.List<java.lang.String> targetUrlList)
Defines the list of HTTP server's target URLs to which resources will be requested.- Parameters:
targetUrlList- list of HTTP server's target URLs
-
getTargetUrlList
public java.util.List<java.lang.String> getTargetUrlList()
-
setTimeout
public void setTimeout(int timeout)
Defines the timeout, in milliseconds. This is used when communicating with the HTTP server. If the timeout expires before the connection can be established or before there is data available for read, aMxConnTimeoutExceptionis raised. A timeout of zero is interpreted as infinite timeout.- Parameters:
timeout-
-
setUserId
public void setUserId(java.lang.String userId)
Defines the user's identification.- Parameters:
userId- user's identification
-
setXmlCharValidationEnabled
public void setXmlCharValidationEnabled(boolean enabled)
Defines if the response message should be validated against invalid XML characters. If enabled, all invalid characters will be removed from the request/response message.- Parameters:
enabled-trueif the message should be validated against invalid XML characters,falseotherwise
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-