Apache JMeter
1.9

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

java.lang.Object
  |
  +--org.apache.jmeter.testelement.AbstractTestElement
        |
        +--org.apache.jmeter.samplers.AbstractSampler
              |
              +--org.apache.jmeter.protocol.http.sampler.HTTPSampler
                    |
                    +--org.apache.jmeter.protocol.http.sampler.WebServiceSampler
All Implemented Interfaces:
Cloneable, Sampler, Serializable, TestElement

public class WebServiceSampler
extends HTTPSampler

Title: JMeter Access Log utilities
Copyright: Apache.org
Company: nobody
License:

Look at the apache license at the top.

Description:
Sampler to handle Web Service requests. It uses Apache soap drivers to perform the XML generation, connection, soap encoding and other soap functions.
Author: Peter Lin
Version: 0.1
Created on: Jun 26, 2003

Version:
$Id:
Author:
Peter Lin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSampler
HTTPSampler.Test
 
Field Summary
static String MEMORY_CACHE
           
static String READ_RESPONSE
           
static String SOAP_ACTION
           
protected  String SOAPACTION
          The SOAPAction is required by MS webservices and is defined by the WSDL.
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.HTTPSampler
ARGUMENTS, AUTH_MANAGER, conn, CONTENT_TYPE, COOKIE_MANAGER, DEFAULT_PROTOCOL, DOMAIN, ENCODED_PATH, encoding, FILE_DATA, FILE_FIELD, FILE_MIMETYPE, FILE_NAME, FOLLOW_REDIRECTS, GET, HEADER, HEADER_MANAGER, HEADERS, IMAGE_PARSER, METHOD, MIMETYPE, MULTIPART_FORM, NON_HTTP_RESPONSE_CODE, NON_HTTP_RESPONSE_MESSAGE, NORMAL_FORM, PATH, PORT, POST, PROTOCOL, UNSPECIFIED_PORT, URL, USE_KEEPALIVE
 
Fields inherited from class org.apache.jmeter.testelement.AbstractTestElement
log
 
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.
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
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 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 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 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
addArgument, addArgument, addProperty, addTestElement, disconnect, getArguments, getAuthManager, getCookieManager, getDomain, getEncodedPath, getFileField, getFilename, getFollowRedirects, getHeaderManager, getMethod, getMimetype, getPath, getPort, getProtocol, getQueryString, getResponseHeaders, getUrl, getUseKeepAlive, isImageParser, parseArguments, readResponse, removeArguments, sendPostData, setArguments, setAuthManager, setCookieManager, setDomain, setEncodedPath, setFileField, setFilename, setFollowRedirects, setHeaderManager, setImageParser, setMethod, setMimetype, setPath, setPort, setPostHeaders, setProperty, setProtocol, setupConnection, setUseKeepAlive, toString
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
clear, clone, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, isRunningVersion, logProperties, mergeIn, nextIsNull, propertyIterator, recoverRunningVersion, removeProperty, setName, setProperty, setRunningVersion, 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
clear, clone, getProperty, getPropertyAsBoolean, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, isRunningVersion, propertyIterator, recoverRunningVersion, removeProperty, setProperty, setRunningVersion, 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

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

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.


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


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


getSoapAction

public String getSoapAction()
return the soap action string

Returns:
String soap action

setMemoryCache

public void setMemoryCache(boolean cache)
set the memory 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.


getReadResponse

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

Returns:
boolean

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.

Returns:
Document

sample

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

Specified by:
sample in interface Sampler
Overrides:
sample in class HTTPSampler
Parameters:
e - Entry to be sampled
Returns:
results of the sampling

sample

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

Overrides:
sample in class HTTPSampler
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 HTTPSampler

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.

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.

Overrides:
connect in class HTTPSampler
IOException

Apache JMeter
1.9

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