Apache JMeter
2.0.1.20050615

org.apache.jmeter.protocol.http.sampler
Class WebServiceSampler

java.lang.Object
  extended byorg.apache.jmeter.testelement.AbstractTestElement
      extended byorg.apache.jmeter.samplers.AbstractSampler
          extended byorg.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
              extended byorg.apache.jmeter.protocol.http.sampler.HTTPSampler
                  extended byorg.apache.jmeter.protocol.http.sampler.WebServiceSampler
All Implemented Interfaces:
Cloneable, Sampler, Serializable, TestElement, TestListener

public class WebServiceSampler
extends HTTPSampler

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

Version:
$Revision: 1.15 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSampler
HTTPSampler.Test
 
Field Summary
protected  String FILE_CONTENTS
           
static String MEMORY_CACHE
           
static String PROXY_HOST
           
static String PROXY_PORT
           
static String READ_RESPONSE
           
static String SOAP_ACTION
           
protected  String SOAPACTION
          The SOAPAction is required by MS webservices and is defined by the WSDL.
static String USE_PROXY
           
protected static javax.xml.parsers.DocumentBuilder XDB
          We make DocumentBuilder static.
static String XML_DATA
           
static String XML_DATA_FILE
           
static String XML_PATH_LOC
           
protected  org.w3c.dom.Document XMLMSG
          The XML document
 
Fields inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
ARGUMENTS, AUTH_MANAGER, AUTO_REDIRECTS, CONTENT_TYPE, COOKIE_MANAGER, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT, DEFAULT_PROTOCOL, DOMAIN, FILE_DATA, FILE_FIELD, FILE_MIMETYPE, FILE_NAME, FOLLOW_REDIRECTS, GET, HEADER_MANAGER, IMAGE_PARSER, MAX_FRAME_DEPTH, MAX_REDIRECTS, METHOD, MIMETYPE, MONITOR, MULTIPART_FORM, NON_HTTP_RESPONSE_CODE, NON_HTTP_RESPONSE_MESSAGE, NORMAL_FORM, PATH, PORT, POST, PROTOCOL, UNSPECIFIED_PORT, URL, USE_KEEPALIVE
 
Fields inherited from interface org.apache.jmeter.testelement.TestElement
ENABLED, GUI_CLASS, NAME, TEST_CLASS
 
Constructor Summary
WebServiceSampler()
           
 
Method Summary
 void addEncodedArgument(String name, String value, String metaData)
          We override this to prevent the wrong encoding and provide no implementation.
 void checkProxy()
          The method will check to see if JMeter was started in NonGui mode.
protected  long connect()
          We override this to prevent the wrong encoding and provide no implementation.
 org.w3c.dom.Element createDocument()
          This method uses Apache soap util to create the proper DOM elements.
 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.
 boolean getUseProxy()
          Return whether or not to use proxy
 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.
protected  org.w3c.dom.Document openDocument(String key)
          Open the file and create a Document.
 SampleResult sample()
          sample() does the following: create a new SampleResult, call sampleWithApache, and return the result.
 SampleResult sample(Entry e)
          sample(Entry e) simply calls sample().
 void sampleWithApache()
          Sample the URL using Apache SOAP driver.
 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.
protected  HttpURLConnection setupConnection(URL u, String method)
          We override this to prevent the wrong encoding and provide no implementation.
 void setUseProxy(boolean proxy)
          Set whether or not to use a proxy
 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.HTTPSampler
disconnect, getResponseHeaders, modifyHeaderValues, readResponse, sample, sendPostData, setPostHeaders, setupConnection
 
Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
addArgument, addArgument, addTestElement, clone, downloadPageResources, encodeSpaces, errorResult, getArguments, getAuthManager, getCookieManager, getDomain, getFileField, getFilename, getFollowRedirects, getHeaderManager, getMethod, getMimetype, getMonitor, getPath, getPort, getProtocol, getQueryString, getUrl, getUseKeepAlive, isImageParser, isMonitor, parseArguments, setArguments, setAuthManager, setCookieManager, setDomain, setFileField, setFilename, setFollowRedirects, setHeaderManager, setImageParser, setMethod, setMimetype, setMonitor, setPath, setPort, setProtocol, setUseKeepAlive, testEnded, testEnded, testIterationStart, testStarted, testStarted, toString
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addProperty, canRemove, clear, clearTemporary, emptyTemporary, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, logProperties, mergeIn, nextIsNull, propertyIterator, recoverRunningVersion, removeProperty, setName, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse, traverseCollection, traverseMap, traverseProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jmeter.testelement.TestElement
canRemove, clear, getProperty, getPropertyAsBoolean, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse
 

Field Detail

XML_DATA

public static final String XML_DATA
See Also:
Constant Field Values

SOAP_ACTION

public static final String SOAP_ACTION
See Also:
Constant Field Values

XML_DATA_FILE

public static final String XML_DATA_FILE
See Also:
Constant Field Values

XML_PATH_LOC

public static final String XML_PATH_LOC
See Also:
Constant Field Values

MEMORY_CACHE

public static final String MEMORY_CACHE
See Also:
Constant Field Values

READ_RESPONSE

public static final String READ_RESPONSE
See Also:
Constant Field Values

USE_PROXY

public static final String USE_PROXY
See Also:
Constant Field Values

PROXY_HOST

public static final String PROXY_HOST
See Also:
Constant Field Values

PROXY_PORT

public static final String PROXY_PORT
See Also:
Constant Field Values

SOAPACTION

protected String SOAPACTION
The SOAPAction is required by MS webservices and is defined by the WSDL.


XMLMSG

protected org.w3c.dom.Document XMLMSG
The XML document


XDB

protected static javax.xml.parsers.DocumentBuilder XDB
We make DocumentBuilder static. I'm not sure that this is thread safe. Should investigate this further to make sure it's ok. Making it non-static could mean a performance hit to get a new DocumentBuilder for each request. If it's not safe to use static here, then we should consider using Apache commons pool to create a pool of document builders or make sure XMLParserUtils creates builders efficiently.


FILE_CONTENTS

protected String FILE_CONTENTS
Constructor Detail

WebServiceSampler

public WebServiceSampler()
Method Detail

setXmlPathLoc

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


getXmlPathLoc

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


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 -

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 -

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 -

getSoapAction

public String getSoapAction()
Return the soap action string.

Returns:
String soap action

setMemoryCache

public void setMemoryCache(boolean cache)
Set the memory cache.

Parameters:
cache -

getMemoryCache

public boolean getMemoryCache()
Get the memory cache.

Returns:
boolean cache

setReadResponse

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

Parameters:
read -

getReadResponse

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

Returns:
boolean

setUseProxy

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

Parameters:
proxy -

getUseProxy

public boolean getUseProxy()
Return whether or not to use proxy

Returns:
true if should use proxy

setProxyHost

public void setProxyHost(String host)
Set the proxy hostname

Parameters:
host -

getProxyHost

public String getProxyHost()
Return the proxy hostname

Returns:
the proxy hostname

setProxyPort

public void setProxyPort(String port)
Set the proxy port

Parameters:
port -

getProxyPort

public int getProxyPort()
Return the proxy port

Returns:
the proxy port

checkProxy

public void checkProxy()
The method will check to see if JMeter was started in NonGui mode. If it was, it will try to pick up the proxy host and port values if they were passed to JMeter.java.


createDocument

public org.w3c.dom.Element createDocument()
This method uses Apache soap util to create the proper DOM elements.

Returns:
Element

openDocument

protected org.w3c.dom.Document openDocument(String key)
Open the file and create a Document.

Parameters:
key -
Returns:
Document

sample

public SampleResult sample(Entry e)
sample(Entry e) simply calls sample().

Specified by:
sample in interface Sampler
Overrides:
sample in class HTTPSamplerBase
Parameters:
e - - ignored
Returns:
the sample Result

sample

public SampleResult sample()
sample() does the following: create a new SampleResult, call sampleWithApache, and return the result.

Overrides:
sample in class HTTPSamplerBase
Returns:
SampleResult

sampleWithApache

public void sampleWithApache()
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.


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

setupConnection

protected HttpURLConnection setupConnection(URL u,
                                            String method)
                                     throws IOException
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.

Throws:
IOException

connect

protected long connect()
                throws IOException
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.

Throws:
IOException

Apache JMeter
2.0.1.20050615

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