<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>indiWiz.com &#187; rest</title>
	<atom:link href="http://indiwiz.com/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Wed, 03 Mar 2010 13:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Accessing RESTful WebServices with Prototype.js</title>
		<link>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/</link>
		<comments>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 07:30:14 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=396</guid>
		<description><![CDATA[We can make Ajax requests using Prototype.js (version 1.6.0.3) thus: var url = ...; new Ajax.Request( url, { method:'DELETE', onComplete:function doMessage(response){ alert(response.status); } }); While working on this code, we found out that the method parameter accepted only GET or POST requests. When we give any other request type like DELETE or PUT, the Prototype.js [...]]]></description>
			<content:encoded><![CDATA[<p>We can make Ajax requests using <a href="http://www.prototypejs.org/">Prototype.js</a> (version 1.6.0.3) thus:</p>
<pre class="brush: jscript;">
var url = ...;
new Ajax.Request(
            url,
            {
               method:'DELETE',
               onComplete:function doMessage(response){
                   alert(response.status);
               }
            });
</pre>
<p>While working on this code, we found out that the <tt>method</tt> parameter accepted only GET or POST requests. When we give any other request type like DELETE or PUT, the Prototype.js library converted the request to POST.</p>
<p><a href="http://www.linkedin.com/in/arunjeganath">Arun Jeganath</a> found <a href="https://prototype.lighthouseapp.com/projects/8886/tickets/289-allow-put-delete-and-other-http-methods-on-ajax-requests">this post</a> where the same issue is discussed. The problem was solved when we commented these lines from the Prototype.js code:</p>
<pre>
      if (!['get', 'post'].include(this.method)) {
        //simulate other verbs over post
        params['_method'] = this.method;
        this.method = 'post';
      }
</pre>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;title=Accessing+RESTful+WebServices+with+Prototype.js" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;title=Accessing+RESTful+WebServices+with+Prototype.js" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;title=Accessing+RESTful+WebServices+with+Prototype.js&amp;desc=We%20can%20make%20Ajax%20requests%20using%20Prototype.js%20%28version%201.6.0.3%29%20thus%3A%0D%0A%0D%0A%5Bsourcecode%20language%3D%22javascript%22%5D%0D%0Avar%20url%20%3D%20...%3B%0D%0Anew%20Ajax.Request%28%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20url%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20method%3A%27DELETE%27%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20onComplete%3Afunction%20doMessage%28response%29%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alert%28response." rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;t=Accessing+RESTful+WebServices+with+Prototype.js" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;title=Accessing+RESTful+WebServices+with+Prototype.js&amp;summary=We%20can%20make%20Ajax%20requests%20using%20Prototype.js%20%28version%201.6.0.3%29%20thus%3A%0D%0A%0D%0A%5Bsourcecode%20language%3D%22javascript%22%5D%0D%0Avar%20url%20%3D%20...%3B%0D%0Anew%20Ajax.Request%28%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20url%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20method%3A%27DELETE%27%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20onComplete%3Afunction%20doMessage%28response%29%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alert%28response.&amp;source=indiWiz.com" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/&amp;title=Accessing+RESTful+WebServices+with+Prototype.js" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with JBoss RESTEasy 1.0</title>
		<link>http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/</link>
		<comments>http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 11:07:43 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jax-rs]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=176</guid>
		<description><![CDATA[So ready to jump start into JBoss RESTEasy? Dive! Writing the JAX-RS Class The first step, let us write a simple echo service using JAX-RS: package testpackage; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path(&#34;/echo&#34;) public class Echo { @GET @Path(&#34;/{message}&#34;) public Response echoService(@PathParam(&#34;message&#34;) String message){ return Response.status(200).entity(message).build(); } } Adding the JBoss RESTEasy [...]]]></description>
			<content:encoded><![CDATA[<p>So ready to jump start into <a href="http://www.jboss.org/resteasy/">JBoss RESTEasy</a>? Dive!</p>
<h3>Writing the JAX-RS Class</h3>
<p>The first step, let us write a simple echo service using JAX-RS:</p>
<pre class="brush: java;">
package testpackage;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path(&quot;/echo&quot;)
public class Echo {
    @GET
    @Path(&quot;/{message}&quot;)
    public Response echoService(@PathParam(&quot;message&quot;) String message){
        return Response.status(200).entity(message).build();
    }
}
</pre>
<h3>Adding the JBoss RESTEasy dependency to Maven project</h3>
<p>If you are using Maven to build your projects, add the dependency for RESTEasy:</p>
<pre class="brush: xml;">
&lt;dependency&gt;
    &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
    &lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
    &lt;version&gt;1.0.0.GA&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>Also remember to add the JBoss repository to the <tt>pom.xml</tt> (RESTEasy is not available in Maven public repository):</p>
<pre class="brush: xml;">
&lt;repository&gt;
    &lt;id&gt;jboss&lt;/id&gt;
    &lt;url&gt;http://repository.jboss.com/maven2/&lt;/url&gt;
    &lt;releases&gt;
        &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/releases&gt;
    &lt;snapshots&gt;
        &lt;enabled&gt;false&lt;/enabled&gt;
    &lt;/snapshots&gt;
&lt;/repository&gt;
</pre>
<h3>Configuring web.xml</h3>
<p>The bare minimum needed to have RESTEasy running is:</p>
<pre class="brush: xml;">
&lt;web-app ...&gt;
    ...
    &lt;listener&gt;
        &lt;listener-class&gt;org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap&lt;/listener-class&gt;
    &lt;/listener&gt;

    &lt;servlet&gt;
        &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
        &lt;servlet-class&gt;org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher&lt;/servlet-class&gt;
    &lt;/servlet&gt;

    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    ...
&lt;/web-app&gt;
</pre>
<p>Above, we have just added the RESTEasy servlet and listener. Now we have to make it load our JAX-RS class. This can be done in two ways. One, just let RESTEasy scan the CLASSPATH to identify and load JAX-RS resources:</p>
<pre class="brush: xml;">
&lt;web-app ...&gt;
    ...
    &lt;context-param&gt;
        &lt;param-name&gt;resteasy.scan&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/context-param&gt;
    ...
&lt;/web-app&gt;
</pre>
<p>The other option is to specify the resources manually (use CSV format):</p>
<pre class="brush: xml;">
&lt;web-app ...&gt;
    ...
    &lt;context-param&gt;
        &lt;param-name&gt;resteasy.resources&lt;/param-name&gt;
        &lt;param-value&gt;testpackage.Echo&lt;/param-value&gt;
    &lt;/context-param&gt;
    ...
&lt;/web-app&gt;
</pre>
<p>After deploying this, you may access your application (if your are using default Tomcat/Jetty installation): <a href="http://localhost:8080/resteasytest/echo/hello,world">http://localhost:8080/resteasytest/echo/hello,world</a> (assumes your application is deployed as <tt>resteasytest.war</tt>)</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;title=Getting+started+with+JBoss+RESTEasy+1.0" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;title=Getting+started+with+JBoss+RESTEasy+1.0" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;title=Getting+started+with+JBoss+RESTEasy+1.0&amp;desc=So%20ready%20to%20jump%20start%20into%20JBoss%20RESTEasy%3F%20Dive%21%0A%0AWriting%20the%20JAX-RS%20Class%0A%0AThe%20first%20step%2C%20let%20us%20write%20a%20simple%20echo%20service%20using%20JAX-RS%3A%0A%0A%5Bsourcecode%20language%3D%27java%27%5D%0Apackage%20testpackage%3B%0A%0Aimport%20javax.ws.rs.GET%3B%0Aimport%20javax.ws.rs.Path%3B%0Aimport%20javax.ws.rs.PathParam%3B%0Aimport%20javax.ws.rs.core.Res" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;t=Getting+started+with+JBoss+RESTEasy+1.0" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;title=Getting+started+with+JBoss+RESTEasy+1.0&amp;summary=So%20ready%20to%20jump%20start%20into%20JBoss%20RESTEasy%3F%20Dive%21%0A%0AWriting%20the%20JAX-RS%20Class%0A%0AThe%20first%20step%2C%20let%20us%20write%20a%20simple%20echo%20service%20using%20JAX-RS%3A%0A%0A%5Bsourcecode%20language%3D%27java%27%5D%0Apackage%20testpackage%3B%0A%0Aimport%20javax.ws.rs.GET%3B%0Aimport%20javax.ws.rs.Path%3B%0Aimport%20javax.ws.rs.PathParam%3B%0Aimport%20javax.ws.rs.core.Res&amp;source=indiWiz.com" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/&amp;title=Getting+started+with+JBoss+RESTEasy+1.0" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/01/26/getting-started-with-jboss-resteasy-10/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
