Interface Client

All Known Implementing Classes:
ApacheHttpClient, SoapClient, WSClient

public interface Client
Copyright 2014 Michael Rice Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

  • Method Details

    • invoke

      Object invoke(String methodName, Argument[] paras, String returnType) throws RemoteException
      Invoke a given method with supplied Argument on the remote vi server. This method typically creates the payload needed to send to the vi server. For example you would pass in RetrieveServiceContent for the methodName, next the params needed for the method. Next give the returnType the parser should convert the response to in this case the string ServiceContent

      Returns an Object of the given return type. Using the example above you would get a ServiceContent Object.

      Parameters:
      methodName - Name of the method to execute
      paras - Array of Arguments aka params for the method
      returnType - String name of the return type
      Returns:
      Object
      Throws:
      RemoteException
    • invokeAsString

      StringBuffer invokeAsString(String methodName, Argument[] paras) throws RemoteException
      Invoke a given method with supplied Argument on the remote vi server. Returns a StringBuffer This works the same as the above call except there is no conversion done on the return data and instead you just get back the StringBuffer content.
      Parameters:
      methodName - Name of the method to execute
      paras - Array of Arguments aka params for the method
      Returns:
      StringBuffer with the
      Throws:
      RemoteException
    • getBaseUrl

      URL getBaseUrl()
      Returns the URL that will be used in the connection.
      Returns:
      URL of the vi server used by this Client
    • setBaseUrl

      void setBaseUrl(URL baseUrl)
      Set the baseUrl for use in this Client
      Parameters:
      baseUrl - URL to be used by this Client
    • getCookie

      String getCookie()
      Returns the String of the Cookie from the Set-Cookie header unless it was manually set in which case it returns that.
      Returns:
      String from the Set-Cookie header
    • setCookie

      void setCookie(String cookie)
      Primarily used to set the cookie from the Set-Cookie header
      Parameters:
      cookie - String from the Set-Cookie header
    • getVimNameSpace

      String getVimNameSpace()
      Get the vim namespace used in SOAP payloads
      Returns:
      vim namespace used in SOAP Payloads
    • setVimNameSpace

      void setVimNameSpace(String vimNameSpace)
      Sets the vim name space for the SOAP payload.
      Parameters:
      vimNameSpace - String
    • getConnectTimeout

      int getConnectTimeout()
      Basic getter
      Returns:
      Time in milliseconds as an int
    • setConnectTimeout

      void setConnectTimeout(int timeoutMilliSec)
      Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this Client. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. This is only used if your client supports this setting.

      Some non-standard implementation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().

      Parameters:
      timeoutMilliSec - an int that specifies the connect timeout value in milliseconds
    • getReadTimeout

      int getReadTimeout()
      Returns the time in milliseconds that is set for the read timeout

      This time may not be the same as what the underlying client uses. If for example the client does not support this and is for some reason hard coded to some value this value.

      Returns:
      Time in milliseconds
    • setReadTimeout

      void setReadTimeout(int timeoutMilliSec)
      Set the read timeout.

      Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.

      This value will be used by the underlying http client used if it is supported. By default that is the WSClient which uses HTTPURLConnection which uses URLConnection

      Parameters:
      timeoutMilliSec - Integer time in milliseconds
    • getTrustManager

      TrustManager getTrustManager()
    • setSoapActionOnApiVersion

      void setSoapActionOnApiVersion(String apiVersion)
      Sets the api version. The oldest supported will be v4.0
      Parameters:
      apiVersion - String with the api version.
    • marshall

      String marshall(String methodName, Argument[] paras)
      Marshal the JAVA Object into a XML payload to send to the server
      Parameters:
      methodName - String Name of the method to execute
      paras - Array of Arguments aka params for the method
      Returns:
    • unMarshall

      Object unMarshall(String returnType, InputStream is) throws Exception
      Convert from an InputStream filled with an XML response from the server to a given JAVA Object of returnType
      Parameters:
      returnType -
      is -
      Returns:
      Throws:
      Exception
    • readStream

      StringBuffer readStream(InputStream stream) throws IOException
      Read an InputStream filled with an XML response from the server.
      Parameters:
      stream -
      Returns:
      Throws:
      IOException