com.ibm.integration.admin.http

Class HttpClient

  • java.lang.Object
    • com.ibm.integration.admin.http.HttpClient


  • public class HttpClient
    extends java.lang.Object

    A local HTTP client for connecting to local integration nodes and servers using local communications

    • Constructor Summary

      Constructors 
      Constructor and Description
      HttpClient(java.lang.String nodeName)
      Asks the IBM Integration API to construct a local HTTP client for your Integration Node.
      HttpClient(java.lang.String hostname, int port, java.lang.String userId, java.lang.String password, boolean useSSL)
      Asks the IBM Integration API to construct a remote HTTP client for your Integration Server.
      HttpClient(java.lang.String serverName, java.lang.String workPath)
      Asks the IBM Integration API to construct a local HTTP client for your Integration Server.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      HttpResponse deleteMethod(java.lang.String urlPath)
      Call this method with a url on your HTTP client to remove a resource using DELETE The urlPath will be encoded before the request is sent.
      HttpResponse deleteMethod(java.lang.String urlPath, boolean encodePath)
      Call this method with a url on your HTTP client to remove a resource using DELETE
      int getConnectionTimeout()
      Get the connection timeout (seconds) that is used for connecting to a remote Integration Node or Integration Server
      HttpResponse getMethod(java.lang.String urlPath)
      Call this method with a url on your HTTP client to access a resource using GET The urlPath will be encoded before the request is sent.
      HttpResponse getMethod(java.lang.String urlPath, boolean encodePath)
      Call this method with a url on your HTTP client to access a resource using GET
      boolean isLocalClient() 
      HttpResponse patchMethod(java.lang.String urlPath, java.lang.String body)
      Call this method with a url and body to update a resource using PATCH The urlPath will be encoded before the request is sent.
      HttpResponse patchMethod(java.lang.String urlPath, java.lang.String body, boolean encodePath)
      Call this method with a url and body to update a resource using PATCH
      HttpResponse postMethod(java.lang.String urlPath, java.io.File file)
      Call this method with a url and POST a file on your HTTP client This can be used for deploying a BAR file to an Integration Server The urlPath will be encoded before the request is sent.
      HttpResponse postMethod(java.lang.String urlPath, java.io.File file, boolean encodePath)
      Call this method with a url and POST a file on your HTTP client
      HttpResponse postMethod(java.lang.String urlPath, java.io.InputStream inputStream, java.lang.String fileName)
      Call this method with a url and POST a file via a InputStream to your HTTP client This can be used for deploying a BAR file to an Integration Server The urlPath will be encoded before the request is sent.
      HttpResponse postMethod(java.lang.String urlPath, java.io.InputStream inputStream, java.lang.String fileName, boolean encodePath)
      Call this method with a url and POST a file via a InputStream to your HTTP client This can be used for deploying a BAR file to an Integration Server
      HttpResponse postMethod(java.lang.String urlPath, java.lang.String body)
      Call this method with a url and body to create a resource using POST The urlPath will be encoded before the request is sent.
      HttpResponse postMethod(java.lang.String urlPath, java.lang.String body, boolean encodePath)
      Call this method with a url and body to create a resource using POST
      void setConnectionTimeout(int connectionTimeout)
      Set the connection timeout (seconds) that is used for connecting to a remote Integration Node or Integration Server
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • X_IBM_BIP_Client_Version

        public static final java.lang.String X_IBM_BIP_Client_Version
        See Also:
        Constant Field Values
      • X_IBM_BIP_Client

        public static final java.lang.String X_IBM_BIP_Client
        See Also:
        Constant Field Values
      • productVersion

        public static java.lang.String productVersion
    • Constructor Detail

      • HttpClient

        public HttpClient(java.lang.String nodeName)
        Asks the IBM Integration API to construct a local HTTP client for your Integration Node. No active connection will be made until your first http method call
        Parameters:
        nodeName - The local integration node name HttpClient an object that represents the local HTTP client which can be used to communicate with an Integration Node using getMethod, postMethod and deleteMethod
      • HttpClient

        public HttpClient(java.lang.String serverName,
                          java.lang.String workPath)
        Asks the IBM Integration API to construct a local HTTP client for your Integration Server. No active connection will be made until your first HTTP method call
        Parameters:
        serverName - The local integration server name
        workPath - The workPath for your integration server (currently /tmp/mqsi for linux) ("" for Windows) HttpClient an object that represents the local HTTP client which can be used to communicate with an Integration Server using getMethod, postMethod and deleteMethod
      • HttpClient

        public HttpClient(java.lang.String hostname,
                          int port,
                          java.lang.String userId,
                          java.lang.String password,
                          boolean useSSL)
        Asks the IBM Integration API to construct a remote HTTP client for your Integration Server. No active connection will be made until your first HTTP method call
        Parameters:
        hostname - The hostname of the machine where the Integration Node or Integration Server is running
        port - The port of the machine where the Integration Node or Integration Server is running
        userId - The userId for performing administrative tasks if Admin Security is enabled. Use "" if Admin Security is not enabled.
        password - The password for the userId if Admin Security is enabled.
        useSSL - Set to true if SSL is enabled on the Integration Node or Integration Server. HttpClient an object that represents the local HTTP client which can be used to communicate with an Integration Server using getMethod, postMethod and deleteMethod
    • Method Detail

      • isLocalClient

        public boolean isLocalClient()
      • getConnectionTimeout

        public int getConnectionTimeout()
        Get the connection timeout (seconds) that is used for connecting to a remote Integration Node or Integration Server
        Returns:
        connectionTimeout
      • setConnectionTimeout

        public void setConnectionTimeout(int connectionTimeout)
        Set the connection timeout (seconds) that is used for connecting to a remote Integration Node or Integration Server
        Parameters:
        connectionTimeout -
      • getMethod

        public HttpResponse getMethod(java.lang.String urlPath)
                               throws java.io.FileNotFoundException,
                                      java.io.UnsupportedEncodingException,
                                      java.io.IOException,
                                      java.lang.InterruptedException,
                                      java.net.ConnectException,
                                      java.net.MalformedURLException,
                                      java.net.SocketTimeoutException
        Call this method with a url on your HTTP client to access a resource using GET The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - to call eg. /apiv2/servers
        Returns:
        The HttpResponse
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • getMethod

        public HttpResponse getMethod(java.lang.String urlPath,
                                      boolean encodePath)
                               throws java.io.FileNotFoundException,
                                      java.io.UnsupportedEncodingException,
                                      java.io.IOException,
                                      java.lang.InterruptedException,
                                      java.net.ConnectException,
                                      java.net.MalformedURLException,
                                      java.net.SocketTimeoutException
        Call this method with a url on your HTTP client to access a resource using GET
        Parameters:
        urlPath - the path to call eg. /apiv2/servers
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The HttpResponse
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.lang.String body)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and body to create a resource using POST The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - eg /apiv2/servers
        body - eg {"name": "IS1"} to create integration server called IS1
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.lang.String body,
                                       boolean encodePath)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and body to create a resource using POST
        Parameters:
        urlPath - eg /apiv2/servers
        body - eg {"name": "IS1"} to create integration server called IS1
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.io.File file)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and POST a file on your HTTP client This can be used for deploying a BAR file to an Integration Server The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - to call eg. /apiv2/servers/is1/deploy
        file - eg /home/myBAR.bar to deploy a bar file
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.io.File file,
                                       boolean encodePath)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and POST a file on your HTTP client
        Parameters:
        urlPath - to call eg. /apiv2/servers/is1/deploy
        file - eg /home/myBAR.bar to deploy a bar file
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.io.InputStream inputStream,
                                       java.lang.String fileName)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and POST a file via a InputStream to your HTTP client This can be used for deploying a BAR file to an Integration Server The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - to call eg. /apiv2/servers/is1/deploy
        inputStream - contains the contents to deploy
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • postMethod

        public HttpResponse postMethod(java.lang.String urlPath,
                                       java.io.InputStream inputStream,
                                       java.lang.String fileName,
                                       boolean encodePath)
                                throws java.io.FileNotFoundException,
                                       java.io.UnsupportedEncodingException,
                                       java.io.IOException,
                                       java.lang.InterruptedException,
                                       java.net.ConnectException,
                                       java.net.MalformedURLException,
                                       java.net.SocketTimeoutException
        Call this method with a url and POST a file via a InputStream to your HTTP client This can be used for deploying a BAR file to an Integration Server
        Parameters:
        urlPath - to call eg. /apiv2/servers/is1/deploy
        inputStream - contains the contents to deploy
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • patchMethod

        public HttpResponse patchMethod(java.lang.String urlPath,
                                        java.lang.String body)
                                 throws java.io.FileNotFoundException,
                                        java.io.UnsupportedEncodingException,
                                        java.io.IOException,
                                        java.lang.InterruptedException,
                                        java.net.ConnectException,
                                        java.net.MalformedURLException,
                                        java.net.SocketTimeoutException
        Call this method with a url and body to update a resource using PATCH The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - eg /apiv2/servers/myserver/statistics/snapshot
        body - eg {"properties": {"publicationOn": "active"}} to turn on publication statistics on myserver
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • patchMethod

        public HttpResponse patchMethod(java.lang.String urlPath,
                                        java.lang.String body,
                                        boolean encodePath)
                                 throws java.io.FileNotFoundException,
                                        java.io.UnsupportedEncodingException,
                                        java.io.IOException,
                                        java.lang.InterruptedException,
                                        java.net.ConnectException,
                                        java.net.MalformedURLException,
                                        java.net.SocketTimeoutException
        Call this method with a url and body to update a resource using PATCH
        Parameters:
        urlPath - eg /apiv2/servers/myserver/statistics/snapshot
        body - eg {"properties": {"publicationOn": "active"}} to turn on publication statistics on myserver
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The complete HTTP response including status code
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • deleteMethod

        public HttpResponse deleteMethod(java.lang.String urlPath)
                                  throws java.io.FileNotFoundException,
                                         java.io.UnsupportedEncodingException,
                                         java.io.IOException,
                                         java.lang.InterruptedException,
                                         java.net.ConnectException,
                                         java.net.MalformedURLException,
                                         java.net.SocketTimeoutException
        Call this method with a url on your HTTP client to remove a resource using DELETE The urlPath will be encoded before the request is sent.
        Parameters:
        urlPath - to remove a resource /apiv2/servers/server1
        Returns:
        The HttpResponse
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException
      • deleteMethod

        public HttpResponse deleteMethod(java.lang.String urlPath,
                                         boolean encodePath)
                                  throws java.io.FileNotFoundException,
                                         java.io.UnsupportedEncodingException,
                                         java.io.IOException,
                                         java.lang.InterruptedException,
                                         java.net.ConnectException,
                                         java.net.MalformedURLException,
                                         java.net.SocketTimeoutException
        Call this method with a url on your HTTP client to remove a resource using DELETE
        Parameters:
        urlPath - to remove a resource /apiv2/servers/server1
        encodePath - whether to encode the path or not. true will cause the path to be encoded. false will cause the path to not be encoded. use false if the path is already encoded.
        Returns:
        The HttpResponse
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.io.UnsupportedEncodingException
        java.lang.InterruptedException
        java.net.ConnectException
        java.net.MalformedURLException
        java.net.SocketTimeoutException