Class SoapClient

java.lang.Object
com.vmware.vim25.ws.SoapClient
All Implemented Interfaces:
Client
Direct Known Subclasses:
ApacheHttpClient, WSClient

public abstract class SoapClient extends Object implements Client
Created by Michael Rice on 8/10/14.

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.

  • Field Details

    • soapAction

      public String soapAction
    • baseUrl

      public URL baseUrl
    • thumbprint

      public String thumbprint
    • vimNameSpace

      public String vimNameSpace
    • connectTimeout

      public int connectTimeout
    • readTimeout

      public int readTimeout
    • trustManager

      protected TrustManager trustManager
  • Constructor Details

    • SoapClient

      public SoapClient()
  • Method Details

    • setSoapActionOnApiVersion

      public void setSoapActionOnApiVersion(String apiVersion)
      Description copied from interface: Client
      Sets the api version. The oldest supported will be v4.0
      Specified by:
      setSoapActionOnApiVersion in interface Client
      Parameters:
      apiVersion - String with the api version.
    • getBaseUrl

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

      public void setBaseUrl(URL baseUrl)
      Set the baseUrl for use in this Client
      Specified by:
      setBaseUrl in interface Client
      Parameters:
      baseUrl -
    • getCookie

      public String getCookie()
      Returns the String of the Cookie from the Set-Cookie header unless it was manually set in which case it returns that.
      Specified by:
      getCookie in interface Client
      Returns:
      String from the Set-Cookie header
    • setServerThumbprint

      public void setServerThumbprint(String thumbprint)
    • getServerThumbprint

      public String getServerThumbprint()
    • computeX509CertificateThumbprint

      public static String computeX509CertificateThumbprint(X509Certificate cert)
    • hexify

      public static String hexify(byte[] bytes)
    • setCookie

      public void setCookie(String cookie)
      Primarily used to set the cookie from the Set-Cookie header
      Specified by:
      setCookie in interface Client
      Parameters:
      cookie - String from the Set-Cookie header
    • getVimNameSpace

      public String getVimNameSpace()
      Description copied from interface: Client
      Get the vim namespace used in SOAP payloads
      Specified by:
      getVimNameSpace in interface Client
      Returns:
    • setVimNameSpace

      public void setVimNameSpace(String vimNameSpace)
      Description copied from interface: Client
      Sets the vim name space for the SOAP payload.
      Specified by:
      setVimNameSpace in interface Client
      Parameters:
      vimNameSpace -
    • getConnectTimeout

      public int getConnectTimeout()
      Description copied from interface: Client
      Basic getter
      Specified by:
      getConnectTimeout in interface Client
      Returns:
      Time in milliseconds as an int
    • setConnectTimeout

      public void setConnectTimeout(int timeoutMilliSec)
      Description copied from interface: Client
      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().

      Specified by:
      setConnectTimeout in interface Client
      Parameters:
      timeoutMilliSec -
    • getReadTimeout

      public 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.

      Specified by:
      getReadTimeout in interface Client
      Returns:
      int
    • setReadTimeout

      public 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

      Specified by:
      setReadTimeout in interface Client
      Parameters:
      timeoutMilliSec - int
    • getTrustManager

      public TrustManager getTrustManager()
      Specified by:
      getTrustManager in interface Client
    • readStream

      public StringBuffer readStream(InputStream is) throws IOException
      Description copied from interface: Client
      Read an InputStream filled with an XML response from the server.
      Specified by:
      readStream in interface Client
      Parameters:
      is -
      Returns:
      Throws:
      IOException
    • marshall

      public String marshall(String methodName, Argument[] paras)
      This method will marshall the java payload object in to xml payload.
      Specified by:
      marshall in interface Client
      Parameters:
      methodName -
      paras -
      Returns:
      String - XML SoapMessage
    • unMarshall

      public Object unMarshall(String returnType, InputStream is) throws Exception
      This method will unmarshall the response inputstream to Java Object of returnType type.
      Specified by:
      unMarshall in interface Client
      Parameters:
      returnType -
      is -
      Returns:
      Object - Converted Response inputstream
      Throws:
      Exception