<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Using the RESTeasy Project Example and the WS Tester
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/bfitzpat">Brian Fitzpatrick</a> in <i>JBoss Tools</i> - <a href="http://community.jboss.org/community/jbosstools/blog/2010/06/28/using-the-resteasy-project-example-and-the-ws-tester">View the full blog post</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>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 <a class="" href="http://community.jboss.org/wiki/UsingtheRESTEasySimpleProjectExampleinJBDS3">this wiki page</a>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To do this yourself, follow these steps:</p><ol><li><p>Grab a recent build of JBoss Tools 3.2 (go [<a class="jive-link-external-small" href="http://download.jboss.org/jbosstools/builds/nightly/" target="_blank">http://download.jboss.org/jbosstools/builds/nightly/</a> and use the latest trunk build). Install it into an Eclipse 3.6 (Helios) instance.</p></li><li><p>Make sure you have an EAP 5 or SOA-P 5 runtime ready with RESTeasy installed.</p></li><li><p>Fire up your Eclipse workbench and follow the steps <a class="" href="http://community.jboss.org/wiki/UsingtheRESTEasySimpleProjectExampleinJBDS3">here</a> to get your RESTful web service project into your workbench (steps 1 through 10).</p></li><li><p>Get a bit familiar with the WS Tester by checking out <a class="jive-link-blog-small" href="http://community.jboss.org/community/jbosstools/blog/2010/05/26/testing-web-services">this post</a> and <a class="jive-link-blog-small" href="http://community.jboss.org/community/jbosstools/blog/2010/06/04/testing-web-services-from-wsdls">this post</a>.</p></li><li><p>Open the WS Tester view by selecting Window-&gt;Show View-&gt;Other... Drill down until you find "JBoss Tools Web Services" and select the Web Service Tester.</p></li><li><p>To post a new customer to the service database:</p><ul><li><p>Select JAX-RS as your Web Service Type.</p></li><li><p>Switch the HTTP Method to "POST".</p></li><li><p><span>Type in your Service URL: </span><a class="jive-link-external-small" href="http://localhost:8080/simple/rest-services/customers" target="_blank">http://localhost:8080/simple/rest-services/customers</a><span>.</span></p></li><li><p>Put in your sample XML in the Request Body tab:</p><pre><code>&lt;customer&gt;<br clear="none"/>&lt;first-name&gt;Bill&lt;/first-name&gt;<br clear="none"/>&lt;last-name&gt;Burke&lt;/last-name&gt;<br clear="none"/>&lt;street&gt;256 Red Hat Lane&lt;/street&gt;<br clear="none"/>&lt;city&gt;Boston&lt;/city&gt;<br clear="none"/>&lt;state&gt;MA&lt;/state&gt;&lt;zip&gt;02115&lt;/zip&gt;<br clear="none"/>&lt;country&gt;USA&lt;/country&gt;<br clear="none"/>&lt;/customer&gt;</code></pre></li><li><p>On the Request Header tab, add "content-type=application/xml" as the lone header.</p></li><li><p>Click the Invoke button.</p></li><li><p><span>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 (</span><a class="jive-link-external-small" href="http://localhost:8080/simple/rest-services/customers/#" target="_blank">http://localhost:8080/simple/rest-services/customers/#</a><span> where # is the record number for the entry).</span></p></li></ul></li><li><p>To retrieve a record from the service:&#160;&#160;&#160;&#160;&#160;&#160; </p><ul><li><p>Change the HTTP Method to "GET".</p></li><li><p><span>Change the Service URL to the Location value you saw in step 6 (</span><a class="jive-link-external-small" href="http://localhost:8080/simple/rest-services/customers/1" target="_blank">http://localhost:8080/simple/rest-services/customers/1</a><span>)</span></p></li><li><p>Click the Invoke button.<br/><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1841-3575/rest_get_1.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1841-3575/450-243/rest_get_1.jpg </span></a></p></li><li><p>This time you should see the XML record in the Response Body tab and [HTTP/1.1 200 OK] as the first Response Header.<br/><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1841-3576/rest_get_1_headers.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1841-3576/432-450/rest_get_1_headers.jpg </span></a></p></li></ul></li><li><p>To update a record from the service:</p><ul><li><p>Change the HTTP Method to "PUT".</p></li><li><p>Leave the URL the same (for the record you want to update).</p></li><li><p>Provide the updated XML for the record:</p><pre><code>&lt;customer&gt;<br clear="none"/>&lt;first-name&gt;Gary&lt;/first-name&gt;<br clear="none"/>&lt;last-name&gt;Lamperillo&lt;/last-name&gt;<br clear="none"/>&lt;street&gt;123 Red Hat Court&lt;/street&gt;<br clear="none"/>&lt;city&gt;Venice&lt;/city&gt;<br clear="none"/>&lt;state&gt;CA&lt;/state&gt;<br clear="none"/>&lt;zip&gt;90291&lt;/zip&gt;<br clear="none"/>&lt;country&gt;USA&lt;/country&gt;<br clear="none"/>&lt;/customer&gt;</code></pre></li><li><p>Click the Invoke button.</p></li><li><p>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.</p></li><li><p>To verify that the data went through correctly, we can do another GET - simply switch the HTTP Method to "GET" and click Invoke again.<br/><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1841-3577/rest_get_2.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1841-3577/450-244/rest_get_2.jpg </span></a></p></li><li><p>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.</p></li></ul></li></ol><p>And that's it! Pretty easy. Didn't even have to leave Eclipse to test!</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/community/jbosstools/blog/2010/06/28/using-the-resteasy-project-example-and-the-ws-tester">going to Community</a></p>

</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>