Actually I did those test by modifying EJB and WS classes by extends them from "AbstractJavaSamplerClient" and added my codes on "runTest()" method like this :
Web Service Sample
public SampleResult runTest(JavaSamplerContext context) {
SampleResult result = new SampleResult();
String result1 = "";
try{
JMeterVariables vars = JMeterContextService.getContext().getVariables();
vars.put("WebService", "WebServiceVariableContent");
result.sampleStart();
HelloWorldService service = new HelloWorldService();
HelloWorldPortType port = service.getHelloWorldPortTypePort();
long s = System.currentTimeMillis();
result1 = port.sayHelloWorld("10000", "500");
long f = System.currentTimeMillis();
LogUtil.log("******** WEB SRVICE ******** Start on : " + s
+ " and end at : " + f + " --> Webservice takes " + (f - s)
/ 1000 + " second", Level.INFO, null);
System.out.println("********* RESULT from WebService ***********");
System.out.println(result);
System.out.println("********************************************");
result.sampleEnd();
result.setSuccessful(true);
result.setSampleLabel("SUCCESS: " + result1);
} catch (Throwable e) {
result.sampleEnd();
result.setSampleLabel("FAILED: '" + e.getMessage() + "' || " + e.toString());
result.setSuccessful(false);
e.printStackTrace();
System.out.println("\n\n\n");
}
return result;
}
EJB Remote Sample
public SampleResult runTest(JavaSamplerContext context) {
SampleResult result = new SampleResult();
String result1 = "";
try{
JMeterVariables vars = JMeterContextService.getContext().getVariables();
vars.put("EJBRemote", "EJBRemoteVariableContent");
result.sampleStart();
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "weblogic");
env.put(Context.PROVIDER_URL, "t3://46.34.96.70:1087");
Context ctx = new InitialContext(env);
System.out.println("Initial Context created");
long s = System.currentTimeMillis();
helloWorld = (HelloWorld) ctx
.lookup("HelloWorld#server.com.demo.HelloWorld");
long f = System.currentTimeMillis();
LogUtil.log("******** EJB REMOTE ******** Start on : "+s+" and end at : "+f+" --> Webservice takes "+(f - s)/1000 + " second",Level.INFO, null);
System.out.println("lookup successful");
System.out.println("Calling EJB method . . .");
result1=helloWorld.sayHello("10000","50000");
System.out.println("Output will be in Managed server console");
System.out.println("********* RESULT from EJB Remote ***********");
System.out.println(result1);
System.out.println("********************************************");
result.sampleEnd();
result.setSuccessful(true);
result.setSampleLabel("SUCCESS: " + result1);
} catch (Throwable e) {
result.sampleEnd();
result.setSampleLabel("FAILED: '" + e.getMessage() + "' || " + e.toString());
result.setSuccessful(false);
e.printStackTrace();
System.out.println("\n\n\n");
}
return result;
}
Then You should create jar files from them (Easily I just used export option in MyEclipse) and copy them (with external jar files if need) to JMETER_HOME/lib/ext .
Further from JMeter desktop application I added "Java Request" sampler and chose the my desired class from classname option.
Now you could add some listener to see the test results .
Hope it could be helpful.