You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by sn...@apache.org on 2002/07/29 19:32:22 UTC
cvs commit: xml-soap/java/samples/stringarray DeploymentDescriptor.xml README StringArray.java StringArrayClient.java test.cmd
snichol 2002/07/29 10:32:21
Added: java/samples/stringarray DeploymentDescriptor.xml README
StringArray.java StringArrayClient.java test.cmd
Log:
A (somewhat) spruced-up version of some code I created in April 2001 for
performance testing.
A client of the service Sends an array of strings. Depending on the method
called, the service will either return nothing (the accept method),
the array of strings (the echo method), or the concatenation of the
strings in the array (the concat method). The accept method can be
used to measure server processing time or as a baseline for client
tests. The concat method can be used as a baseline to compare client XML
processing, since the return will have fewer nodes. The echo method
can be used to measure client XML processing.
The client provided is designed to perform SOAP RPC calls multiple
times in a loop. It also allows many performance-related
parameters to be specified on the command line. The NT
command file test.cmd is an example of how to use this client
to test the affect of various parameter settings.
Revision Changes Path
1.1 xml-soap/java/samples/stringarray/DeploymentDescriptor.xml
Index: DeploymentDescriptor.xml
===================================================================
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn:StringArray">
<isd:provider type="java"
scope="Application"
methods="accept concat echo">
<isd:java class="samples.stringarray.StringArray" static="false"/>
</isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
<isd:mappings>
</isd:mappings>
</isd:service>
1.1 xml-soap/java/samples/stringarray/README
Index: README
===================================================================
Service:
-------
To install this service on an Apache-SOAP listener, you need to make
the samples.stringarray package available on the Apache-SOAP listener's
classpath. Then deploy this service by filling in the deployment
template using the info in the deployment descriptor in this
directory or by using the service manager client:
java org.apache.soap.server.ServiceManagerClient routerURL deploy dd.xml
where routerURL is the URL of the SOAP RPC router and dd.xml is the
name of the deployment descriptor file. For example:
java org.apache.soap.server.ServiceManagerClient \
http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml
Client:
------
Run the following client to see the usage:
java samples.stringarray.StringArrayClient
This client is designed to perform SOAP RPC calls multiple
times in a loop. It also allows many performance-related
parameters to be specified on the command line. The NT
command file test.cmd is an example of how to use this client
to test the affect of various parameter settings.
Additional Client Classpath Requirements:
----------------------------------------
../..
Explanation:
-----------
Sends an array of strings to the service. Depending on the method
called, the service will either return nothing (the accept method),
the array of strings (the echo method), or the concatenation of the
strings in the array (the concat method). The accept method can be
used to measure server processing time or as a baseline for client
tests. The echo method can be used to measure client XML processing.
The concat method can be used as a baseline to compare client XML
processing, since the return will have fewer nodes.
Sample Usage:
------------
java samples.stringarray.StringArrayClient \
http://192.168.0.4:8888/soap/servlet/rpcrouter echo 1234567890 10 50 512 false true
1.1 xml-soap/java/samples/stringarray/StringArray.java
Index: StringArray.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package samples.stringarray;
import java.util.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
/**
*/
public class StringArray
{
public void accept(String[] stringArray) {
}
public String concat(String[] stringArray) {
StringBuffer buf = new StringBuffer(stringArray.length * stringArray[0].length());
for (int i = 0; i < stringArray.length; i++)
buf.append(stringArray[i]);
return buf.toString();
}
public String[] echo(String[] stringArray) {
return stringArray;
}
}
1.1 xml-soap/java/samples/stringarray/StringArrayClient.java
Index: StringArrayClient.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package samples.stringarray;
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.*;
/**
* Executes methods against the StringArray server with settings from
* the command line. This is hopefully useful for testing performance
* of various scenarios with various settings. Note that this is a
* single threaded client.
*
* @author Scott Nichol (snichol@computer.org)
*/
public class StringArrayClient {
public static void main(String[] args) throws Exception {
if (args.length != 8
&& (args.length != 9 || !args[0].startsWith("-"))) {
System.err.println("Usage:");
System.err.println(" java " + StringArrayClient.class.getName() +
" [-encodingStyleURI] SOAP-router-URL accept|concat|echo stringToSend arrayItems loops outputBufferSize tcpNoDelay useDocumentBuilder");
System.exit(1);
}
// Process the arguments.
int offset = 9 - args.length;
String encodingStyleURI = args.length == 9
? args[0].substring(1)
: Constants.NS_URI_SOAP_ENC;
URL url = new URL(args[1 - offset]);
String method = args[2 - offset];
if (!(method.equals("accept") || method.equals("concat") || method.equals("echo"))) {
System.err.println(method + " is not a valid method. Must be accept|concat|echo");
System.exit(1);
}
String stringToSend = args[3 - offset];
int strings = Integer.parseInt(args[4 - offset]);
int calls = Integer.parseInt(args[5 - offset]);
int outputBufferSize = Integer.parseInt(args[6 - offset]);
Boolean tcpNoDelay = Boolean.valueOf(args[7 - offset]);
boolean useDocumentBuilder = Boolean.valueOf(args[8 - offset]).booleanValue();
// Build the call.
Call call = new Call();
call.setSOAPMappingRegistry(new SOAPMappingRegistry());
call.setTargetObjectURI("urn:StringArray");
call.setMethodName(method);
call.setEncodingStyleURI(encodingStyleURI);
Vector params = new Vector();
String[] stringArray = new String[strings];
for (int i = 0; i < strings; i++)
stringArray[i] = stringToSend;
params.addElement(new Parameter("stringArray", stringArray.getClass(),
stringArray, null));
call.setParams(params);
SOAPHTTPConnection st = new SOAPHTTPConnection();
st.setOutputBufferSize(outputBufferSize);
st.setTcpNoDelay(tcpNoDelay);
call.setSOAPTransport(st);
call.setUseDocumentBuilder(useDocumentBuilder);
// Invoke the call.
Response resp;
long time0 = System.currentTimeMillis();
long time1 = time0;
int faults = 0;
for (int i = 0; i < calls; i++) {
try {
resp = call.invoke(url, "");
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" +
e.getFaultCode() + "): " +
e.getMessage());
return;
}
// Check the response.
if (!resp.generatedFault()) {
Parameter ret = resp.getReturnValue();
Object value = (ret != null) ? ret.getValue() : null;
} else {
Fault fault = resp.getFault();
faults++;
}
if (i == 0)
time1 = System.currentTimeMillis();
}
long time2 = System.currentTimeMillis();
System.out.println("Time (ms): " + (time2 - time0));
System.out.println("Time1 (ms): " + (time1 - time0));
System.out.println("Faults: " + faults);
System.out.println("URL: " + url);
System.out.println("Method: " + method);
System.out.println("StringToSend: " + stringToSend);
System.out.println("ArrayItems: " + strings);
System.out.println("Loops: " + calls);
System.out.println("OutputBufferSize: " + outputBufferSize);
System.out.println("TcpNoDelay: " + tcpNoDelay);
System.out.println("UseDocumentBuilder: " + useDocumentBuilder);
System.err.println(calls + " calls with " + strings + " " + stringToSend + " with buffer size " + outputBufferSize + ", " + faults + " faults, in " + (time2 - time0) + " millis");
}
}
1.1 xml-soap/java/samples/stringarray/test.cmd
Index: test.cmd
===================================================================
@echo off
rem
rem Set COMMAND and OUTPUT
rem
rem set COMMAND=java -classic -Djava.compiler= samples.stringarray.StringArrayClient http://192.168.0.4:8888/soap/servlet/rpcrouter
rem set OUTPUT=test-northgate-classic.out
set COMMAND=java samples.stringarray.StringArrayClient http://192.168.0.4:8888/soap/servlet/rpcrouter
set OUTPUT=test-northgate.out
rem
rem Make sure the servlet is loaded...
rem
echo Make sure the servlet is loaded...
%COMMAND% accept 1234567890 1 1 512 false true
rem
rem Prepare output
rem
del %OUTPUT% 2>nul
echo Writing output to %OUTPUT%
rem
rem Vary calls
rem
:calls
echo Vary calls
%COMMAND% accept 1234567890 10 400 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 50 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 200 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 400 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 800 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 10 1600 512 false true >>%OUTPUT%
rem
rem Vary string size
rem
:string
echo Vary string size
%COMMAND% accept 12345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 12345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 12345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% echo 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
rem
rem Vary array size and parsing
rem
:array
echo Vary array size with DocumentBuilder
%COMMAND% accept 1234567890 80 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 20 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 40 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 80 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 160 100 512 false true >>%OUTPUT%
%COMMAND% echo 1234567890 320 100 512 false true >>%OUTPUT%
echo Vary array size with Transform
%COMMAND% accept 1234567890 80 100 512 false false >>%OUTPUT%
%COMMAND% echo 1234567890 20 100 512 false false >>%OUTPUT%
%COMMAND% echo 1234567890 40 100 512 false false >>%OUTPUT%
%COMMAND% echo 1234567890 80 100 512 false false >>%OUTPUT%
%COMMAND% echo 1234567890 160 100 512 false false >>%OUTPUT%
%COMMAND% echo 1234567890 320 100 512 false false >>%OUTPUT%
rem
rem Vary output buffer size and Nagle
rem
:buffer
echo Vary output buffer size with Nagle enabled
%COMMAND% accept 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 128 false true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 false true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 1024 false true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 2048 false true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 8192 false true >>%OUTPUT%
echo Vary output buffer size with Nagle disabled
%COMMAND% accept 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 true true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 128 true true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 512 true true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 1024 true true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 2048 true true >>%OUTPUT%
%COMMAND% concat 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 10 100 8192 true true >>%OUTPUT%
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>