title: Test Web service performance using Jmeter in Java
body: <p>I need to test the performance of a web service method using <code>Jmeter</code> in <code>Java</code>, i found that <code>Jmeter</code> API provide <code>StandardJMeterEngine</code> class to run test method by <code>Jmeter</code>, and using parameter of type "<code>String</code>":</p>
  
  <pre><code>public class JMeterTestFromCode {
      public static void main(String[] args) {
          // Engine
          StandardJMeterEngine jm = new StandardJMeterEngine();
          // jmeter.properties
          JMeterUtils.loadJMeterProperties("c:/tmp/jmeter.properties");
          HashTree hashTree = new HashTree();
          // HTTP Sampler
          HTTPSampler httpSampler = new HTTPSampler();
          httpSampler.setDomain("www.google.com");
          httpSampler.setPort(80);
          httpSampler.setPath("/");
          httpSampler.setMethod("GET");
          // Loop Controller
          TestElement loopCtrl = new LoopController();
          ((LoopController) loopCtrl).setLoops(1);
          ((LoopController) loopCtrl).addTestElement(httpSampler);
          ((LoopController) loopCtrl).setFirst(true);
          // Thread Group
          SetupThreadGroup threadGroup = new SetupThreadGroup();
          threadGroup.setNumThreads(1);
          threadGroup.setRampUp(1);
          threadGroup.setSamplerController((LoopController) loopCtrl);
          // Test plan
          TestPlan testPlan = new TestPlan("MY TEST PLAN");
          hashTree.add("testPlan", testPlan);
          hashTree.add("loopCtrl", loopCtrl);
          hashTree.add("threadGroup", threadGroup);
          hashTree.add("httpSampler", httpSampler);
          jm.configure(hashTree);
          jm.run();
      }
  }
  </code></pre>
  
  <p>my problem is that i'm using a web service of an EJB, this web service uses custom parameters (bean objects), here after how i run it by Soap :</p>
  
  <pre><code>String ENDPOINT_ADDRESS = "http://server:8080/server-ejb/MyServiceClass?wsdl";
  QName SERVICE_DATA_FINDER = new QName(
      "http://test.service.com/", "MyServiceClass");
  javax.xml.ws.Service service;
  
      service = javax.xml.ws.Service.create(
              new URL(ENDPOINT_ADDRESS), SERVICE_DATA_FINDER);
      IMyServiceClass finder = service.getPort(IMyServiceClass.class);
      MyBean bean = new MyBean();
      // bean.set...
      // bean.set...
      finder.myMethod("foo", bean);
  </code></pre>
  
  <p>The goal is to create a Maven project that provide an automated performance test for the Web-Service + retrieving test result (that's why i need to implement WS test in Jmeter using Java)</p>
  
  <p>How can i test my web service using StandardJMeterEngine or other API ?</p>
  
  <p>Thanks in advance !</p>