org.apache.jmeter.protocol.http.sampler

Class WebServiceSampler

Implemented Interfaces:
Cloneable, HTTPConstantsInterface, Sampler, Serializable, TestElement, TestListener, 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

Field Summary

Fields inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase

ARGUMENTS, AUTH_MANAGER, AUTO_REDIRECTS, CACHE_MANAGER, CLIENT, CONNECT_TIMEOUT, CONTENT_ENCODING, CONTENT_TYPE, COOKIE_MANAGER, DEFAULT_METHOD, DOMAIN, DO_MULTIPART_POST, EMBEDDED_URL_RE, FOLLOW_REDIRECTS, HEADER_MANAGER, IMAGE_PARSER, IMPLEMENTATION, MAX_FRAME_DEPTH, MAX_REDIRECTS, METHOD, MONITOR, NON_HTTP_RESPONSE_CODE, NON_HTTP_RESPONSE_MESSAGE, PATH, PORT, PROTOCOL, RESPONSE_TIMEOUT, UNSPECIFIED_PORT, UNSPECIFIED_PORT_AS_STRING, URL, URL_UNSPECIFIED_PORT, URL_UNSPECIFIED_PORT_AS_STRING, USE_KEEPALIVE

Fields inherited from interface org.apache.jmeter.protocol.http.util.HTTPConstantsInterface

APPLICATION_X_WWW_FORM_URLENCODED, CONNECTION_CLOSE, DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_PORT_STRING, DEFAULT_HTTP_PORT, DEFAULT_HTTP_PORT_STRING, DELETE, ENCODING_GZIP, ETAG, GET, HEAD, HEADER_AUTHORIZATION, HEADER_CONNECTION, HEADER_CONTENT_DISPOSITION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_COOKIE, HEADER_LOCATION, HEADER_SET_COOKIE, HTTP_1_1, IF_MODIFIED_SINCE, IF_NONE_MATCH, KEEP_ALIVE, LAST_MODIFIED, MULTIPART_FORM_DATA, OPTIONS, POST, PROTOCOL_HTTP, PROTOCOL_HTTPS, PUT, TRACE, TRANSFER_ENCODING

Fields inherited from interface org.apache.jmeter.testelement.TestElement

COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS

Method Summary

void
addEncodedArgument(String name, String value, String metaData)
We override this to prevent the wrong encoding and provide no implementation.
String
convertSoapHeaders(Hashtable ht)
boolean
getMemoryCache()
Get the memory cache.
String
getProxyHost()
Return the proxy hostname
int
getProxyPort()
Return the proxy port
protected String
getRandomFileName()
Method is used internally to check if a random file should be used for the message.
boolean
getReadResponse()
Return whether or not to read the response.
String
getSoapAction()
Return the soap action string.
String
getTimeout()
int
getTimeoutAsInt()
boolean
getUseProxy()
Return whether or not to use proxy
String
getWsdlURL()
method returns the WSDL URL
String
getXmlData()
Get the XML data as a string.
String
getXmlFile()
Get the file location of the xml file.
String
getXmlPathLoc()
Get the path where XML messages are stored. this is the directory where JMeter will randomly select a file.
SampleResult
sample()
Sample the URL using Apache SOAP driver.
protected HTTPSampleResult
sample(URL u, String s, boolean b, int i)
Samples the URL passed in and stores the result in HTTPSampleResult, following redirects and downloading page resources as appropriate.
void
setMemoryCache(boolean cache)
Set the memory cache.
void
setProxyHost(String host)
Set the proxy hostname
void
setProxyPort(String port)
Set the proxy port
void
setReadResponse(boolean read)
Set whether the sampler should read the response or not.
void
setSoapAction(String data)
Set the soap action which should be in the form of an URN.
void
setTimeout(String text)
void
setUseProxy(boolean proxy)
Set whether or not to use a proxy
void
setWsdlURL(String url)
void
setXmlData(String data)
Set the XML data.
void
setXmlFile(String filename)
it's kinda obvious, but we state it anyways.
void
setXmlPathLoc(String path)
Set the path where XML messages are stored for random selection.

Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase

addArgument, addArgument, addEncodedArgument, addEncodedArgument, addEncodedArgument, addNonEncodedArgument, addTestElement, clone, downloadPageResources, encodeBackSlashes, encodeSpaces, errorResult, followRedirects, getArguments, getAuthManager, getAutoRedirects, getCacheManager, getClient, getConnectTimeout, getContentEncoding, getCookieManager, getDefaultPort, getDoMultipartPost, getDomain, getEmbeddedUrlRE, getFileField, getFilename, getFollowRedirects, getHTTPFileCount, getHTTPFiles, getHeaderManager, getImplementation, getMethod, getMimetype, getMonitor, getPath, getPort, getPortIfSpecified, getProtocol, getQueryString, getQueryString, getResponseTimeout, getSendFileAsPostBody, getSendParameterValuesAsPostBody, getUrl, getUseKeepAlive, getUseMultipartForPost, getValidMethodsAsArray, hasArguments, isImageParser, isMonitor, isProtocolDefaultPort, isSecure, isSecure, isSuccessCode, parseArguments, parseArguments, readResponse, resultProcessing, sample, sample, sample, setArguments, setAuthManager, setAutoRedirects, setCacheManager, setClient, setConnectTimeout, setContentEncoding, setCookieManager, setDoMultipartPost, setDomain, setEmbeddedUrlRE, setFileField, setFilename, setFollowRedirects, setHTTPFiles, setHeaderManager, setImageParser, setImplementation, setMD5, setMethod, setMimetype, setMonitor, setMonitor, setPath, setPath, setPort, setProtocol, setResponseTimeout, setUseKeepAlive, testEnded, testEnded, testIterationStart, testStarted, testStarted, threadFinished, threadStarted, toString, useMD5

Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

addProperty, addTestElement, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty

Method Details

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 interface HTTPSamplerBase

convertSoapHeaders

public String convertSoapHeaders(Hashtable ht)

getMemoryCache

public boolean getMemoryCache()
Get the memory cache.
Returns:
boolean cache

getProxyHost

public String getProxyHost()
Return the proxy hostname
Returns:
the proxy hostname

getProxyPort

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

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

getReadResponse

public boolean getReadResponse()
Return whether or not to read the response.
Returns:
boolean

getSoapAction

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

getTimeout

public String getTimeout()

getTimeoutAsInt

public int getTimeoutAsInt()

getUseProxy

public boolean getUseProxy()
Return whether or not to use proxy
Returns:
true if should use proxy

getWsdlURL

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

getXmlData

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

getXmlFile

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

getXmlPathLoc

public String getXmlPathLoc()
Get the path where XML messages are stored. this is the directory where JMeter will randomly select a file.

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 interface HTTPSamplerBase

sample

protected HTTPSampleResult sample(URL u,
                                  String s,
                                  boolean b,
                                  int i)
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.

Overrides:
sample in interface HTTPSamplerBase
Parameters:
u - URL to sample
Returns:
results of the sampling

setMemoryCache

public void setMemoryCache(boolean cache)
Set the memory cache.
Parameters:
cache -

setProxyHost

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

setProxyPort

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

setReadResponse

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

setSoapAction

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

setTimeout

public void setTimeout(String text)

setUseProxy

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

setWsdlURL

public void setWsdlURL(String url)
Parameters:
url -

setXmlData

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

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 -

setXmlPathLoc

public void setXmlPathLoc(String path)
Set the path where XML messages are stored for random selection.

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.