Oracle SOA Suite 11g Performance Tuning Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a web service test using JMeter

In this recipe, we'll create a JMeter test for a SOA composite.

Getting ready

You'll need to complete the Installing Apache JMeter recipe. We've provided a composite to use in this recipe that is available on the book's website. You can use your own, but the steps will follow the example recipe.

How to do it…

Follow these steps to create a simple web service test:

  1. Start JMeter as per step 4 of the Installing Apache JMeter recipe.
  2. You'll be presented with the JMeter GUI. In the window pane on the left, right-click on the Test Plan flask icon and select Add | Threads | Thread Group. Name the Thread Group as Test Users by changing the text in the name box as shown:
  3. Set Thread Properties so that Number of Threads is 10 and Ramp-Up Period is 15.
  4. Right-click on the Test Users thread group and select Add | Sampler | WebService (SOAP) Request.
  5. Depending upon how the composite to test is loaded on the system, the WSDL location will be different. If you've deployed the test composite for this chapter to a SOA server on the local machine, it will be located at something like http://127.0.0.1:8001/soa-infra/services/default/Project1/bpelprocess1_client_ep?WSDL. Place this in the WSDL URL textbox and select Load WSDL. In the Web Methods drop-down box, select Process, and click on Configure. Finally, set Timeout to a suitable value such as 2000 milliseconds. The JMeter GUI should appear as follows:
  6. Place the following text into the Soap/XML-RPC Data box:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
            <ns1:process xmlns:ns1="http://xmlns.oracle.com/SOAApplication1/Project1/BPELProcess1">
               <ns1:input>1</ns1:input>
            </ns1:process>
    </soap:Body>
    </soap:Envelope>
  7. Ensure that the Options section has the Read SOAP Response checkbox selected, as follows:
  8. Right-click on the Test Users thread group and select Add | Listener | View Results Tree.
  9. Select File | Save, and give the plan a suitable name.
  10. Click on the green run arrow or go to Start | Run to start the test. Click on the View Results Tree item to browse the test result, and data sent and received is in the Request and Response data tabs. If all goes well, you should see a green icon next to Web Service Request, as follows:

How it works…

JMeter uses the concept of samplers, controllers, and listeners to control the sending and capturing of data to and from endpoints. Thread groups then encapsulate the load element of the test, allowing us to control volumes and the rate at which they escalate.

In this recipe, we created a single thread test, which executed only once. We used a SOAP sampler to make it send a SOAP XML test to our SOA Suite composite, by parsing the WSDL exposed by our composite and firing a static SOAP envelope at its exposed address.

We then added a listener to capture the response from the composite, and validated that we received a HTTP 200 response.

There's more…

If you had issues publishing data to your composite, then a good alternative to create a single SOAP message test is to use the Fusion Middleware Control Enterprise Manager application to generate the test SOAP message. To do this, click on the Test button within the composite view. This can give you the exposed WSDL address, endpoint invoked, and request and response information that you can place within JMeter, ensuring that all of the values are correct. Enterprise Manager has a useful, single execution test option, however, this is not suitable for load testing. SOA Infra app exposes a test application, however, this is a beta JavaScript stub and is not suitable for large scale, distributed load testing.

There are a lot of other samplers and elements that we can add to a test plan; of particular use is the ability to save test results for later analysis. The JMeter documentation is the best place to learn about what they can do and how they work.