com.ibm.di.connector.maximo.util
Class HttpClient

java.lang.Object
  extended by com.ibm.di.connector.maximo.util.HttpClient

public final class HttpClient
extends java.lang.Object

HTTP 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
HttpClient(Log log)
           
 
Method Summary
 java.io.InputStream getAsInputStream()
          Requests the resource specified by the target URL list as an input stream.
 java.util.List<java.lang.String> getTargetUrlList()
           
 java.lang.String post(java.lang.String msg)
          Requests the resource specified by the target URL list.
 void setAuthenticationRequired(boolean isRequired)
          Indicates if the authentication header containing the user's credentials should be sent.
 void setPassword(java.lang.String pass)
          Defines the user's password.
 void setTargetUrlList(java.util.List<java.lang.String> targetUrlList)
          Defines the list of HTTP server's target URLs to which resources will be requested.
 void setTimeout(int timeout)
          Defines the timeout, in milliseconds.
 void setUserId(java.lang.String userId)
          Defines the user's identification.
 void setXmlCharValidationEnabled(boolean enabled)
          Defines if the response message should be validated against invalid XML characters.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpClient

public HttpClient(Log log)
Method Detail

getAsInputStream

public java.io.InputStream getAsInputStream()
                                     throws MxConnConfigException,
                                            MxConnIOException
Requests 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 defined
MxConnIOException - 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,
                             MxConnIOException
Requests 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 defined
MxConnIOException - 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 - true if the authentication header should be sent, otherwise false
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, a MxConnTimeoutException is 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 - true if the message should be validated against invalid XML characters, false otherwise

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object