Skip navigation

Now that the WS Tester is getting more stable and feature complete, I wanted to try it against a RESTeasy web service (JAX-RS) deployed against one of our own runtimes. I simply used the steps we'd defined earlier for using the RESTeasy project example on this wiki page.

 

To do this yourself, follow these steps:

  1. Grab a recent build of JBoss Tools 3.2 (go [http://download.jboss.org/jbosstools/builds/nightly/ and use the latest trunk build). Install it into an Eclipse 3.6 (Helios) instance.

  2. Make sure you have an EAP 5 or SOA-P 5 runtime ready with RESTeasy installed.

  3. Fire up your Eclipse workbench and follow the steps here to get your RESTful web service project into your workbench (steps 1 through 10).

  4. Get a bit familiar with the WS Tester by checking out this post and this post.

  5. Open the WS Tester view by selecting Window->Show View->Other... Drill down until you find "JBoss Tools Web Services" and select the Web Service Tester.

  6. To post a new customer to the service database:

    • Select JAX-RS as your Web Service Type.

    • Switch the HTTP Method to "POST".

    • Type in your Service URL: http://localhost:8080/simple/rest-services/customers.

    • Put in your sample XML in the Request Body tab:

      <customer>
      <first-name>Bill</first-name>
      <last-name>Burke</last-name>
      <street>256 Red Hat Lane</street>
      <city>Boston</city>
      <state>MA</state><zip>02115</zip>
      <country>USA</country>
      </customer>
    • On the Request Header tab, add "content-type=application/xml" as the lone header.

    • Click the Invoke button.

    • You won't see anything in the Response Body tab to the right, but if you go to the Response Header, you should see "[HTTP/1.1 201 Created]" as the top line in the list. You should also see the Location (http://localhost:8080/simple/rest-services/customers/# where # is the record number for the entry).

  7. To retrieve a record from the service:     

    • Change the HTTP Method to "GET".

    • Change the Service URL to the Location value you saw in step 6 (http://localhost:8080/simple/rest-services/customers/1)

    • Click the Invoke button.
      rest_get_1.jpg

    • This time you should see the XML record in the Response Body tab and [HTTP/1.1 200 OK] as the first Response Header.
      rest_get_1_headers.jpg

  8. To update a record from the service:

    • Change the HTTP Method to "PUT".

    • Leave the URL the same (for the record you want to update).

    • Provide the updated XML for the record:

      <customer>
      <first-name>Gary</first-name>
      <last-name>Lamperillo</last-name>
      <street>123 Red Hat Court</street>
      <city>Venice</city>
      <state>CA</state>
      <zip>90291</zip>
      <country>USA</country>
      </customer>
    • Click the Invoke button.

    • Like when you POSTed before, you won't see anything in the Response Body, but you should see [HTTP/1.1 204 No Content] as the first item in the Response Header list.

    • To verify that the data went through correctly, we can do another GET - simply switch the HTTP Method to "GET" and click Invoke again.
      rest_get_2.jpg

    • Now we should see the updated data appear in the Response Body and [HTTP/1.1 200 OK] as the first item in the Response Header list.

And that's it! Pretty easy. Didn't even have to leave Eclipse to test!

Filter Blog

By date:
By tag: