Class WebServiceSampler

All Implemented Interfaces:
Serializable, Cloneable, ConfigMergabilityIndicator, Searchable, HTTPConstantsInterface, Sampler, TestElement, TestIterationListener, TestStateListener, ThreadListener

public class WebServiceSampler extends HTTPSamplerBase
Sampler to handle Web Service requests. It uses Apache SOAP drivers to perform the XML generation, connection, SOAP encoding and other SOAP functions.

Created on: Jun 26, 2003

See Also:
  • Field Details

    • MAINTAIN_SESSION_DEFAULT

      public static final boolean MAINTAIN_SESSION_DEFAULT
      See Also:
  • Constructor Details

    • WebServiceSampler

      public WebServiceSampler()
  • Method Details

    • setXmlPathLoc

      public void setXmlPathLoc(String path)
      Set the path where XML messages are stored for random selection.
      Parameters:
      path - where XML messages are stored
    • getXmlPathLoc

      public String getXmlPathLoc()
      Get the path where XML messages are stored. This is the directory where JMeter will randomly select a file.
      Returns:
      path where XML messages are stored
    • setXmlFile

      public void setXmlFile(String filename)
      it's kinda obvious, but we state it anyways. Set the xml file with a string path.
      Parameters:
      filename - path to xml file
    • getXmlFile

      public String getXmlFile()
      Get the file location of the xml file.
      Returns:
      String file path.
    • getRandomFileName

      protected String getRandomFileName()
      Method is used internally to check if a random file should be used for the message. Messages must be valid. This is one way to load test with different messages. The limitation of this approach is parsing XML takes CPU resources, so it could affect JMeter GUI responsiveness.
      Returns:
      String filename
    • setXmlData

      public void setXmlData(String data)
      Set the XML data.
      Parameters:
      data - xml data
    • getXmlData

      public String getXmlData()
      Get the XML data as a string.
      Returns:
      String data
    • setSoapAction

      public void setSoapAction(String data)
      Set the soap action which should be in the form of an URN.
      Parameters:
      data - soap action
    • getSoapAction

      public String getSoapAction()
      Return the soap action string.
      Returns:
      String soap action
    • setMaintainSession

      public void setMaintainSession(boolean maintainSession)
      Set the maintain session option.
      Parameters:
      maintainSession - flag whether to maintain a session
    • getMaintainSession

      public boolean getMaintainSession()
      Get the maintain session option.
      Returns:
      flag whether to maintain a session
    • setMemoryCache

      public void setMemoryCache(boolean cache)
      Set the memory cache.
      Parameters:
      cache - flag whether to use the memory cache
    • getMemoryCache

      public boolean getMemoryCache()
      Get the memory cache.
      Returns:
      flag whether to use the memory cache
    • setReadResponse

      public void setReadResponse(boolean read)
      Set whether the sampler should read the response or not.
      Parameters:
      read - flag whether the response should be read
    • getReadResponse

      public boolean getReadResponse()
      Return whether or not to read the response.
      Returns:
      flag whether the response should be read
    • setUseProxy

      public void setUseProxy(boolean proxy)
      Set whether or not to use a proxy
      Parameters:
      proxy - flag whether to use a proxy
    • getUseProxy

      public boolean getUseProxy()
      Return whether or not to use proxy
      Returns:
      true if a proxy should be used
    • setProxyHost

      public void setProxyHost(String host)
      Set the proxy hostname
      Parameters:
      host - the hostname of the proxy
    • getProxyHost

      public String getProxyHost()
      Return the proxy hostname
      Overrides:
      getProxyHost in class HTTPSamplerBase
      Returns:
      the proxy hostname
    • setProxyPort

      public void setProxyPort(String port)
      Set the proxy port
      Parameters:
      port - the port of the proxy
    • getProxyPort

      public int getProxyPort()
      Return the proxy port
      Returns:
      the proxy port
    • setWsdlURL

      public void setWsdlURL(String url)
      Parameters:
      url - the URL of the WSDL
    • getWsdlURL

      public String getWsdlURL()
      method returns the WSDL URL
      Returns:
      the WSDL URL
    • sample

      protected HTTPSampleResult sample(URL u, String s, boolean b, int i)
      Description copied from class: HTTPSamplerBase
      Samples the URL passed in and stores the result in HTTPSampleResult, following redirects and downloading page resources as appropriate.

      When getting a redirect target, redirects are not followed and resources are not downloaded. The caller will take care of this.

      Specified by:
      sample in class HTTPSamplerBase
      Parameters:
      u - URL to sample
      s - HTTP method: GET, POST,...
      b - whether we're getting a redirect target
      i - Depth of this target in the frame structure. Used only to prevent infinite recursion.
      Returns:
      results of the sampling, can be null if u is in CacheManager
    • sample

      public SampleResult sample()
      Sample the URL using Apache SOAP driver. Implementation note for myself and those that are curious. Current logic marks the end after the response has been read. If read response is set to false, the buffered reader will read, but do nothing with it. Essentially, the stream from the server goes into the ether.
      Overrides:
      sample in class HTTPSamplerBase
      Returns:
      results of the sampling
    • addEncodedArgument

      public void addEncodedArgument(String name, String value, String metaData)
      We override this to prevent the wrong encoding and provide no implementation. We want to reuse the other parts of HTTPSampler, but not the connection. The connection is handled by the Apache SOAP driver.
      Overrides:
      addEncodedArgument in class HTTPSamplerBase
    • convertSoapHeaders

      public String convertSoapHeaders(Map<String,String> ht)
    • getTimeout

      public String getTimeout()
    • getTimeoutAsInt

      public int getTimeoutAsInt()
    • setTimeout

      public void setTimeout(String text)
    • testEnded

      public void testEnded()
      Description copied from class: HTTPSamplerBase

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      Overrides:
      testEnded in class HTTPSamplerBase
      See Also:
    • testEnded

      public void testEnded(String host)
      Description copied from class: HTTPSamplerBase

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      Overrides:
      testEnded in class HTTPSamplerBase
      Parameters:
      host - name of host
      See Also: