<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4411999261438216170</id><updated>2012-01-27T22:53:11.115-08:00</updated><category term='Authentication'/><category term='JBoss'/><category term='Authorization'/><category term='Security'/><category term='Java'/><category term='JAAS'/><title type='text'>Java Developer</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-20216074562544408</id><published>2011-06-15T20:44:00.000-07:00</published><updated>2011-06-15T20:44:38.426-07:00</updated><title type='text'>How to solve javax.net.ssl.SSLHandshakeException?</title><content type='html'>A few days ago, I deployed one of my applications to Weblogic 10.3 AS but it failed to send emails, I was using gmail as my SMTP server and this was the error :&lt;br /&gt;&lt;br /&gt;&lt;i&gt;javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;After many searches I found the solution and now I'm gonna share it with you.&lt;br /&gt;The problem is that the public key of the SMTP server is not imported into JRE's default keystore, in order to import it, you should follow these steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Install OpenSSL (&lt;a href="http://www.openssl.org/"&gt;http://www.openssl.org/&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;Double-click the openssl file from the directory that gets installed&lt;/li&gt;&lt;li&gt;Run:&amp;nbsp;&lt;b style="font-style: italic;"&gt;s_client -connect smtp.gmail.com:465 &lt;/b&gt;(465 is port of SMTP, if you are using another port, use that one)&lt;/li&gt;&lt;li&gt;From the output, you want only the alphanumeric string between the&amp;nbsp;lines&amp;nbsp;which say 'BEGIN CERTIFICATE' and 'END CERTIFICATE' (inclusive). Copy the results into a file called gmail.cert using your favorite text editor.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://3.bp.blogspot.com/-Gfvddtljjsg/Tflz0F9zMaI/AAAAAAAAAH8/5Km2BFb3i4E/s1600/Screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://3.bp.blogspot.com/-Gfvddtljjsg/Tflz0F9zMaI/AAAAAAAAAH8/5Km2BFb3i4E/s400/Screenshot.png" width="400" /&gt;&lt;/a&gt;  &lt;/div&gt;&lt;li&gt;Now its time to import the public key into default keystore. From Java installation's bin directory run:&lt;br /&gt;&lt;b&gt;&lt;i&gt; keytool -import -alias smtp.gmail.com -keystore $JAVA_HOME/jre/lib/security/cacerts -file C:\path\to\gmail.cert&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;table style="background-color: #d3edd1; border: 1px 7FAD7B dashed; width: 100%;"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;* The default keystore password is 'changeit'.&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;This should solve your problem, if you still have problem with Weblogic server, the reason is that Weblogic has it's own default keystore which is located at:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;$ORACLE_HOME/weblogic/wlserver_10.3/server/lib/DemoTrust.jks&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All you need to do is to import gmail.cert into the above keystore in the same way you did for JRE's keystore.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;table style="background-color: #d3edd1; border: 1px 7FAD7B dashed; width: 100%;"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;* The default keystore password is 'DemoTrustKeyStorePassPhrase'.&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-20216074562544408?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/20216074562544408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=20216074562544408' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/20216074562544408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/20216074562544408'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2011/06/how-to-solve-javaxnetsslsslhandshakeexc.html' title='How to solve javax.net.ssl.SSLHandshakeException?'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Gfvddtljjsg/Tflz0F9zMaI/AAAAAAAAAH8/5Km2BFb3i4E/s72-c/Screenshot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-8011645859304979257</id><published>2009-10-24T08:26:00.000-07:00</published><updated>2009-10-24T08:27:23.338-07:00</updated><title type='text'>Page Ranking Implemented in Java</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 13px; color: rgb(51, 51, 51); -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;p style="margin-top: 0px; padding-bottom: 0px; margin-bottom: 0in; "&gt;Within the past few years, Google has become the far most utilized search engine worldwide. This success is because of the high quality results in comparison to other search engines. This high quality result is because of the Page Ranking feature that google is using.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-top: 0px; padding-bottom: 0px; margin-bottom: 0in; "&gt;Each document is assigned with a ranking while it is being indexed. when you search for a keyword, pages with higher page rank are displayed on top.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-top: 0px; padding-bottom: 0px; margin-bottom: 0in; "&gt;The page rank algorithm is found by Google founders Lawrence Page and Sergey Brin.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-top: 0px; padding-bottom: 0px; margin-bottom: 0in; "&gt;In this article we first go through the algorithm and then implement it in Java.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-top: 0px; padding-bottom: 0px; "&gt;The article is available from &lt;a href="http://www.javadev.org/files/Ranking.pdf" title="Page Ranking Implemented in Java" style="color: rgb(35, 85, 135); text-decoration: none; "&gt;http://www.javadev.org/files/Ranking.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The source code is available from &lt;a href="http://www.javadev.org/files/ranking.zip" title="Page Ranking Implemented in Java" style="color: rgb(35, 85, 135); text-decoration: none; "&gt;http://www.javadev.org/files/ranking.zip&lt;/a&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-8011645859304979257?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/8011645859304979257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=8011645859304979257' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8011645859304979257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8011645859304979257'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2009/10/page-ranking-implemented-in-java.html' title='Page Ranking Implemented in Java'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-7439884085256816461</id><published>2008-11-25T08:32:00.000-08:00</published><updated>2008-11-25T08:34:09.876-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authentication'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JAAS'/><category scheme='http://www.blogger.com/atom/ns#' term='JBoss'/><category scheme='http://www.blogger.com/atom/ns#' term='Authorization'/><title type='text'>How to Develop JAAS Security on JBoss AS ?</title><content type='html'>A few days ago I was proposed to develop an airline ticketing system using JavaEE platform. For this system I decided to use EJB3 and JSF running on JBoss application server.&lt;br /&gt;As long as security is a vital concern in such applications, I decided to use JAAS (Java Authentication and Authorization Service) to implement authentication and authorization.&lt;br /&gt;After searching for the required configurations to implement a JAAS based security on JBoss, I couldn’t find anything useful, even in the JBoss documents! (JavaEE developers are not very unfamiliar with this).&lt;br /&gt;It took a while for me to find all the required settings and run my project under JAAS technology on the JBoss application server, so I decided to share my knowledge and document it, hope to be useful for somebody.&lt;br /&gt;&lt;br /&gt;The printable version of this article is available at:&lt;br /&gt;&lt;a href="http://www.javadev.org/files/JAAS-JBoss.pdf"&gt;http://www.javadev.org/files/JAAS-JBoss.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-7439884085256816461?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/7439884085256816461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=7439884085256816461' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/7439884085256816461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/7439884085256816461'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2008/11/how-to-develop-jaas-security-on-jboss.html' title='How to Develop JAAS Security on JBoss AS ?'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-6451960219844096375</id><published>2007-07-31T04:10:00.000-07:00</published><updated>2007-07-31T04:14:38.522-07:00</updated><title type='text'>Hibernate Performance Tuning</title><content type='html'>Performance is one the most important issues in applications. Application Performance depends on a variety of parameters which must be mentioned carefully to prevent bottle nakes in the application.&lt;br /&gt;Performance-tuning your application should first include the most obvious settings,such as the best fetching strategies and use of proxies.&lt;br /&gt;&lt;br /&gt;This is an article about how to tune our hibernate settings to gain the best performance and prevent vulnerable problems.&lt;br /&gt;&lt;br /&gt;You can view a printable version(PDF) of the article at:&lt;br /&gt;&lt;a href="http://www.javadev.org/files/Hibernate%20Performance%20Tuning.pdf"&gt;http://www.javadev.org/files/Hibernate%20Performance%20Tuning.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-6451960219844096375?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/6451960219844096375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=6451960219844096375' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/6451960219844096375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/6451960219844096375'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/hibernate-performance-tuning.html' title='Hibernate Performance Tuning'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-3619167101454845229</id><published>2007-07-28T05:02:00.000-07:00</published><updated>2007-07-28T05:03:26.133-07:00</updated><title type='text'>How to REST?! - RESTing Without JAX-WS</title><content type='html'>During our example we used JAX-WS API to communicate with the web service. Although this is the best way, but there are other ways as well.One of these ways is using HttpURLConnection:&lt;br /&gt;&lt;br /&gt;1. The client uses the URL.openConnection() method to create an instance of HttpURLConnection representing a connection to the Web service’s URL.&lt;br /&gt;&lt;br /&gt;2. HttpURLConnection.connect() sends the HTTP GET request that has been configured using the Web service’s URL.&lt;br /&gt;&lt;br /&gt;3. The Web service processes the request and writes the appropriate XML document to the HTTP response stream.&lt;br /&gt;&lt;br /&gt;4. The HttpURLConnection’s InputStream is used to read the HTTP response’s XML document.&lt;br /&gt;&lt;br /&gt;Exmaple of a non-JAX-WS Client&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;URL url = new URL(""); // the web service URL&lt;br /&gt;HttpURLConnection con = (HttpURLConnection) url.openConnection();&lt;br /&gt;con.setRequestMethod("GET");&lt;br /&gt;con.connect();InputStream in = con.getInputStream();&lt;br /&gt;&lt;br /&gt;byte[] b = new byte[1024]; // 1K buffer&lt;br /&gt;&lt;br /&gt;int result = in.read(b);&lt;br /&gt;while (result != -1) {&lt;br /&gt;System.out.write(b,0,result);&lt;br /&gt;result =in.read(b);&lt;br /&gt;}&lt;br /&gt;in.close();&lt;br /&gt;con.disconnect();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;Note that the in this case the web service does not return the XML message directly in the StreamSource format but it writes the StreamSource result to the response OutputStream.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-3619167101454845229?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/3619167101454845229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=3619167101454845229' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/3619167101454845229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/3619167101454845229'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-resting-without-jax-ws.html' title='How to REST?! - RESTing Without JAX-WS'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-8192555397381241856</id><published>2007-07-28T04:39:00.000-07:00</published><updated>2007-07-28T05:01:44.477-07:00</updated><title type='text'>How to REST?! - XML Transformation</title><content type='html'>In the previous sections, we sent and received XML messages to/from web service.In this communication the client and web service received the XML message in the formats that they were expecting. These formats were defined in the XML schema files. But sometimes we need to adapt ourselves with different formats of information. For example some services may use email instead of username to identify their customers. So we must provide a way for different XML formats to be acceptable by our RESTful web service.Here we need to transform the incoming xml message to an acceptable format. We can use XSLT for this reason.XSLT makes sense as the transformation tool of choice within SOA integration frameworks, because it is a universally accepted standard and the transformation engines that interpret XSLT to perform data transformations keep getting better and faster.&lt;br /&gt;&lt;br /&gt;As an example assume that the authentication message came from the client is in the following format:&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;auth xmlns="http://www.javadev.org/mail" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="http://www.javadev.org/mail&lt;br /&gt;http://javadev.org/rest/auth/mail.xsd"&amp;gt;&lt;br /&gt;&amp;lt;email&amp;gt;foo&amp;lt;/email&amp;gt;&lt;br /&gt;&amp;lt;password&amp;gt;foo&amp;lt;/password&amp;gt;&lt;br /&gt;&amp;lt;/auth&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;As you can see &amp;lt;username&amp;gt; is replaced with &amp;lt;email&amp;gt; , for the authentication service there is no difference between username and email, because both of them are unique. But the main point of the consideration is that currently, when we are parsing the incoming xml document, we expect the &amp;lt;username&amp;gt; element but we are facing an &amp;lt;email&amp;gt; element.To transform the incoming XML document to the expected format we write an XSLT and use it in the JAXP API.The XSLT document is as bellow:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&lt;br /&gt;xmlns:mail=&lt;/span&gt;&lt;/em&gt;&lt;a href="http://www.javadev.org/mail"&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;http://www.javadev.org/mail&lt;/span&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="mail:auth"&amp;gt;&lt;br /&gt;&amp;lt;auth xmlns="http://www.javadev.org/auth" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"&lt;br /&gt;xsi:schemaLocation="http://www.javadev.org/auth&lt;br /&gt;http://javadev.org/rest/auth/auth.xsd"&amp;gt;&lt;br /&gt;&amp;lt;xsl:apply-templates/&amp;gt;&lt;br /&gt;&amp;lt;/auth&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="mail:email"&amp;gt;&lt;br /&gt;&amp;lt;xsl:apply-templates select="./mail:email"/&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="mail:password"&amp;gt;&lt;br /&gt;&amp;lt;xsl:apply-templates select="./mail:password"/&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="mail:email"&amp;gt;&lt;br /&gt;&amp;lt;username&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="."/&amp;gt;&lt;br /&gt;&amp;lt;/username&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="mail:password"&amp;gt;&lt;br /&gt;&amp;lt;password&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="."/&amp;gt;&lt;br /&gt;&amp;lt;/password&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;This XSLT transformer reads the source XML file and converts it to the destination XML format.After creating the XSLT file, we need to apply it to the incoming xml file before parsing it.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;InputStream xslt = this.getClass().getResourceAsStream("mail_to_user.xslt");&lt;br /&gt;try {&lt;br /&gt;TransformerFactory.newInstance().newTransformer(new StreamSource(xslt))&lt;br /&gt;.transform(src, res);&lt;br /&gt;} catch (Exception e) {&lt;br /&gt;e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;The only difference is that we pass the XSLT document as an StreamSource object to the Transformer to use it before converting the incoming StreamSource object to the equivalent OutputStream.So we can convert any format of incoming messages to our desired format before extracting information.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-8192555397381241856?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/8192555397381241856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=8192555397381241856' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8192555397381241856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8192555397381241856'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-xml-transformation.html' title='How to REST?! - XML Transformation'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-3163758584768180238</id><published>2007-07-28T04:32:00.000-07:00</published><updated>2007-07-28T04:57:51.346-07:00</updated><title type='text'>How to REST?! - Authentication Client</title><content type='html'>We are using a simple java application as our client.The client is using the JAX-WS API to communicate with the web service.It first generates an XML message which contains information need to be authenticated.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000;"&gt;&lt;em&gt;info += "&amp;lt;?xml version=\"1.0\"?&amp;gt;";&lt;br /&gt;info += "&amp;lt;auth xmlns=\"http://www.javadev.org/auth\" xmlns:xsi=\"&lt;/em&gt;&lt;em&gt;http://www.w3.org/2001/XMLSchema-instance\&lt;/em&gt;&lt;/span&gt;&lt;span style="color:#990000;"&gt;&lt;em&gt;"+&lt;br /&gt;xsi:schemaLocation=\"&lt;/em&gt;&lt;em&gt;http://www.javadev.org/auth&lt;/em&gt;&lt;/span&gt;&lt;em&gt;&lt;span style="color:#990000;"&gt; \"+&lt;br /&gt;http://www.javadev.org/rest/auth/auth.xsd &amp;gt;";&lt;br /&gt;info += "&amp;lt;username&amp;gt;foo&amp;lt;/username&amp;gt;";&lt;br /&gt;info += "&amp;lt;password&amp;gt;foo&amp;lt;/password&amp;gt;";&lt;br /&gt;info += "&amp;lt;/auth&amp;gt;";&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;As you can see, we are generating an XML message with the Username and Password which must be authenticated in the web service.&lt;br /&gt;&lt;br /&gt;In the client, Service is used to create an instance of javax.xml.ws.Dispatch&lt;source&gt;, which enables XML message-level interaction with the target Web service. Dispatch is the low-level JAX-WS 2.0 API that requires clients to construct messages by working directly with the XML, rather than with a higher- level binding such as JAXB 2.0 schema derived program elements. For many REST proponents, however, this is exactly the programming paradigm they want—direct access to the XML request and response messages.&lt;br /&gt;The client uses the Service.addPort() method to create a port within the Service instance that can be used to access the RESTful web service.&lt;br /&gt;Next, the Service.createDispatch() method is invoked to create an instance of Dispatch&lt;source&gt;—a Dispatch instance that enables you to work with XML request/response messages as instances of javax.xml.transform.Source.&lt;br /&gt;The Dispatch.invoke() method then packages the XML request—per the JAX-WS 2.0 HTTP Binding—and sends it to the RESTful service. The invoke() method waits for the response before returning.The service processes the HTTP GET and sends an HTTP response that includes the XML.The invoke() method returns the response XML message as an instance of Source.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;// Create an InputStream with the authentication info&lt;br /&gt;ByteArrayInputStream bais = new ByteArrayInputStream(info.getBytes());&lt;br /&gt;&lt;br /&gt;QName svcQName = new QName("http://rest", "svc");&lt;br /&gt;QName portQName = new QName("http://rest", "port");&lt;br /&gt;Service svc = Service.create(svcQName);&lt;br /&gt;svc.addPort(portQName, HTTPBinding.HTTP_BINDING, url);&lt;br /&gt;Dispatch&lt;source&gt; dis =&lt;br /&gt;svc.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);&lt;br /&gt;StreamSource result = (StreamSource) dis.invoke(new StreamSource(bais));&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;Notice that you have to create QName instances for the Service instance and the “port” that corresponds to the RESTful Web service. In a SOAP scenario, these qualified names would correspond to the WSDL definitions for the wsdl:service and wsdl:port. Since there is no WSDL when invoking a RESTful service, these QName instances are gratuitous. They are required by the API, but not used to invoke the RESTful service.&lt;br /&gt;The URL used in the addPort method is the URL of your web service for example we used http://localhost:8080/auth/authService which:&lt;br /&gt;&lt;strong&gt;localhost &lt;/strong&gt;is the name/IP of your running application server.&lt;br /&gt;&lt;strong&gt;8080 &lt;/strong&gt;is the port port of your application server.&lt;br /&gt;&lt;strong&gt;auth &lt;/strong&gt;is the context path of your web service which in our example is defined.&lt;br /&gt;&lt;strong&gt;authService &lt;/strong&gt;is the value of serviceName attribute of the @WebServiceProvider annotation in the web service.As you can see the authentication result is returned as an Source object. So we should parse it and extract the message as we did in the web service.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-3163758584768180238?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/3163758584768180238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=3163758584768180238' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/3163758584768180238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/3163758584768180238'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-authentication-client.html' title='How to REST?! - Authentication Client'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-441825815230232798</id><published>2007-07-28T04:27:00.000-07:00</published><updated>2008-11-23T04:43:26.033-08:00</updated><title type='text'>How to REST?! - Authentication Web Service</title><content type='html'>Our web service class starts with three annotations:&lt;br /&gt;&lt;em&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;strong&gt;@ServiceMode(value = Service.Mode.PAYLOAD)&lt;br /&gt;@WebServiceProvider(serviceName = "authService")&lt;br /&gt;@BindingType(value = HTTPBinding.HTTP_BINDING)&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;In the SOAP web services &lt;strong&gt;@ServiceMode&lt;/strong&gt; is set to MESSAGE which indicates that you want to work with the entire SOAP envelop, but in the RESTful web services it is set to PAYLOAD to indicate that we just need the SOAP body of the message.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@WebServiceProvider&lt;/strong&gt; annotation is required for deploying a RESTful web service and its serviceName attribute is used to deploy our web service with a desired name. This name is used in the client application to access the web service.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;@BindingType&lt;/strong&gt; annotation (javax.xml.ws.BindingType) is also defined by the JAX-WS 2.0 specification and is used to specify the binding that should be employed when publishing an endpoint.&lt;br /&gt;The property value indicates the actual binding. In this case, you can see that the value is specified as follow:&lt;br /&gt;value=HTTPBinding.HTTP_BINDING&lt;br /&gt;This indicates that the XML/HTTP binding should be used, rather than the default SOAP 1.1/HTTP. This is how REST endpoints are specified in JAX-WS 2.0—by setting the @BindingType. If one were to leave the @BindingType annotation off this example, the Java EE 5 container would deploy it as a service that expects to receive a SOAP envelope, rather than straight XML over HTTP.&lt;br /&gt;&lt;br /&gt;The web service class should implement the javax.xml.ws.Provider.&lt;br /&gt;This interface enables you to create a web service that works directly with the XML message as an instance of javax.xml.transform.Source.&lt;br /&gt;&lt;br /&gt;The web service class receives the XML message as an instance of javax.xml.transform.Source. So the first step toward authentication is to convert this object to an XML document, then we can parse the XML document to extract our required information.&lt;br /&gt;The transformation is done in the parse(Source src) method which get an Source object as input parameter and returns the parsed XML document.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;ByteArrayOutputStream baos = new ByteArrayOutputStream();&lt;br /&gt;StreamResult res = new StreamResult(baos);&lt;br /&gt;try {&lt;br /&gt;TransformerFactory.newInstance().newTransformer()&lt;br /&gt;.transform(src, res);&lt;br /&gt;} catch (Exception e) {&lt;br /&gt;e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;This code transforms the Source object to an OutputStream object. Then this OutputStream object is converted to an InputStream object and passed to the DomParser to be converted to the parsed XML document (I used the Apache Xerces-J 2 for XML parsing).&lt;br /&gt;ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;try {&lt;br /&gt;InputSource is = new InputSource(bais);&lt;br /&gt;&lt;br /&gt;// Create a DOM Parser&lt;br /&gt;DOMParser parser = new DOMParser();&lt;br /&gt;&lt;br /&gt;// Parsing the incoming file&lt;br /&gt;parser.parse(is);&lt;br /&gt;&lt;br /&gt;// Obtain the document&lt;br /&gt;doc = parser.getDocument();&lt;br /&gt;&lt;br /&gt;} catch (IOException ioe) {&lt;br /&gt;&lt;br /&gt;ioe.printStackTrace();&lt;br /&gt;&lt;br /&gt;} catch (SAXException saxe) {&lt;br /&gt;&lt;br /&gt;saxe.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Once we have the parsed XML document, we can extract the required information needed for the authentication.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NodeList root = doc.getElementsByTagName("auth");&lt;br /&gt;Element rootEL = (Element) root.item(0);&lt;br /&gt;String username = getStringVal(rootEL, "username");&lt;br /&gt;String password = getStringVal(rootEL, "password");&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;Now we have the passed in Username and Password which needs to be authenticated.&lt;br /&gt;After authenticating Username and Password we must return the appropriate message. This message will be and XML message but as an StreamSource object (as the message passed into the web service).&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;if (auth(username, password)) {&lt;br /&gt;String message = "";&lt;br /&gt;&lt;br /&gt;// Write the authentication result to an XML message&lt;br /&gt;message += "";&lt;br /&gt;message += "&amp;lt;result&amp;gt;";&lt;br /&gt;message += "&amp;lt;message&amp;gt;authenticated&amp;lt;/message&amp;gt;";&lt;br /&gt;message += "&amp;lt;/result&amp;gt;";&lt;br /&gt;&lt;br /&gt;// Create an InputStream with the authentication info&lt;br /&gt;ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());&lt;br /&gt;return new StreamSource(bais);&lt;br /&gt;} else {&lt;br /&gt;String message = "";&lt;br /&gt;&lt;br /&gt;// Write the authentication result to an XML message&lt;br /&gt;message += "";&lt;br /&gt;message += "&amp;lt;result&amp;gt;";&lt;br /&gt;message += "&amp;lt;message&amp;gt;failed&amp;lt;/message&amp;gt;";&lt;br /&gt;message += "&amp;lt;/result&amp;gt;";&lt;br /&gt;&lt;br /&gt;// Create an InputStream with the authentication info&lt;br /&gt;ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());&lt;br /&gt;return new StreamSource(bais);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;The client will use the same transformation we did here to parse this XML message and find out the authentication result.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;Deploying the Web Service&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;By using @WebServiceProvider annotation, deploying our web service is as easy as putting the .war file in the deploy directory of the application server. The application server detects it as a web service and deploys it automatically.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-441825815230232798?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/441825815230232798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=441825815230232798' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/441825815230232798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/441825815230232798'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-authentication-web-service.html' title='How to REST?! - Authentication Web Service'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-944110546693268235</id><published>2007-07-28T04:13:00.000-07:00</published><updated>2007-07-28T04:58:55.492-07:00</updated><title type='text'>How to REST?! - Example: Authentication Service</title><content type='html'>As an example we are going to develop an authentication service. This service receives an xml document as input and returns an xml document as output. The input xml document contains username and password which needs to be authenticated and the output xml contains a simple XML message to return the result of authentication to the client.&lt;br /&gt;As the first step, we need to define an interface for our service to format the incoming and outgoing XML documents.Almost all the SOAP-based SOA applications use WSDL to define their interfaces, but in the RESTful application there is no WSDL to use. So we need to find another way for defining our service interfaces.One of the most widely used approaches is using XML Schema.In this example we use a simple XML Schema to restrict the input and output xml messages to our desired format.&lt;br /&gt;&lt;br /&gt;So:&lt;br /&gt;1. XML documents are used to exchange messages between applications.&lt;br /&gt;2. XML Schema documents define the application interfaces.&lt;br /&gt;&lt;br /&gt;Example of incoming XML document:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;&amp;lt;auth xmlns="http://www.javadev.org/auth" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://www.javadev.org/auth http://javadev.org/rest/auth/auth.xsd"&amp;gt;&lt;br /&gt;&amp;lt;username&gt;foo&amp;lt;/username&amp;gt;&lt;br /&gt;&amp;lt;password&gt;foo&amp;lt;/password&amp;gt;&lt;br /&gt;&amp;lt;/auth&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;Example of the schema used as the interface:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;&amp;lt;schema xmlns="http://www.w3.org/2001/XMLSchema" elementformdefault="qualified" targetnamespace="http://www.javadev.org/auth" auth="http://www.javadev.org/auth" xs="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;br /&gt;&amp;lt;element type="xs:string" name="username"&amp;gt;&lt;br /&gt;&amp;lt;element type="xs:string" name="password"&amp;gt;&lt;br /&gt;&amp;lt;element name="auth"&amp;gt;&lt;br /&gt;&amp;lt;complextype&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element ref="auth:username"&amp;gt;&lt;br /&gt;&amp;lt;element ref="auth:password"&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complextype&amp;gt;&lt;br /&gt;&amp;lt;/element&amp;gt;&lt;br /&gt;&amp;lt;/schema&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;Client applications send XML messages to the server in the defined format. This transition is done via the HTTP protocol but the way we use to do this transition varies:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;JAX-WS :&lt;/strong&gt; JAX-WS is a fundamental technology for developing SOAP based and RESTful Java Web services. JAX-WS is designed to take the place of JAX-RPC in Web services and Web applications. We use JAX-WS technology to send/receive XML messages to/from web services. In this approach XML messages are transferred as StreamSource objects and connection to the web service is done via javax.xml.ws.Service and by using Dispatches. This approach will be introduced in more details.&lt;br /&gt;&lt;strong&gt;HttpURLConnection:&lt;/strong&gt; another way to transfer messages between RESTful web services is using HttpURLConnection. In this approach the Web service is accessed with an HTTP GET request. The client application needs to issue the HTTP GET, and process the HTTP response stream that contains the XML document.&lt;br /&gt;&lt;br /&gt;Depends on our requirements, we can use one of the approaches mentioned above.In this article we use JAX-WS API, however we will take a look at the other approach to find out differences.&lt;br /&gt;Our example consists of two parts:&lt;br /&gt;&lt;strong&gt;- Web Service:&lt;/strong&gt; Web Service receives an XML document which needs to be authenticated and returns an XML message which indicates that the authentication was passed or failed.&lt;br /&gt;&lt;strong&gt;- Client:&lt;/strong&gt; Client is an application, It can be a simple java application, another web service or any other kind of application. Client is responsible for sending the authentication XML message and receiving the result XML message.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-944110546693268235?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/944110546693268235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=944110546693268235' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/944110546693268235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/944110546693268235'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-example-authentication.html' title='How to REST?! - Example: Authentication Service'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-7534757640331807832</id><published>2007-07-28T04:00:00.000-07:00</published><updated>2007-07-28T04:11:50.392-07:00</updated><title type='text'>How to REST?! - Definitions</title><content type='html'>&lt;strong&gt;&lt;span style="color:#3366ff;"&gt;What is REST?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term was introduced in the doctoral dissertation in 2000 by Roy Fielding, one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification, and has come into widespread use in the networking community.REST strictly refers to a collection of network architecture principles that outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface that transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3366ff;"&gt;Principles&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;REST's proponents argue that the Web enjoyed the scalability and growth that it has had as a direct result of a few key design principles:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Application state and functionality are divided into resources&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Every resource is uniquely addressable using a universal syntax for use in hypermedia links&lt;br /&gt;&lt;/li&gt;&lt;li&gt;All resources share a uniform interface for the transfer of state between client and resource, consisting of :&lt;br /&gt;-A constrained set of well-defined operations&lt;br /&gt;-A constrained set of content types, optionally supporting code-on-demand&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A protocol that is:&lt;br /&gt;- Client/Server&lt;br /&gt;- Stateless&lt;br /&gt;- Cacheable&lt;br /&gt;- Layered&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;REST's client-server separation of concerns simplifies component implementation, reduces the complexity of connector semantics, improves the effectiveness of performance tuning, and increases the scalability of pure server components. Layered system constraints allow intermediaries--proxies, gateways, and firewalls--to be introduced at various points in the communication without changing the interfaces between components, thus allowing them to assist in communication translation or improve performance via large-scale, shared caching.&lt;br /&gt;REST enables intermediate processing by constraining messages to be self-descriptive: interaction is stateless between requests, standard methods and media types are used to indicate semantics and exchange information, and responses explicitly indicate cache ability.&lt;br /&gt;—Roy Fielding&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3366ff;"&gt;REST vs. RPC&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;A RESTful web application requires a different design approach from an RPC (Remote procedure call) application. An RPC application is exposed as one or more network objects, each with an often unique set of functions that can be invoked. Before a client communicates with the application it must have knowledge of the object identity in order to locate it and must also have knowledge of the object type in order to communicate with it.RESTful design constrains the aspects of a resource that define its interface (the verbs and content types). This leads to the definition of fewer types on the network than an RPC-based application but more resource identifiers (nouns). REST design seeks to define a set of resources that clients can interact with uniformly, and to provide hyperlinks between resources that clients can navigate without requiring knowledge of the whole resource set. Server-provided forms can also be used in a RESTful environment to describe how clients should construct a URL in order to navigate to a particular resource.&lt;br /&gt;—Wikipedia&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-7534757640331807832?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/7534757640331807832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=7534757640331807832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/7534757640331807832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/7534757640331807832'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-definitions.html' title='How to REST?! - Definitions'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-8710475034087969808</id><published>2007-07-28T03:58:00.000-07:00</published><updated>2007-07-28T05:08:11.735-07:00</updated><title type='text'>How to REST?!</title><content type='html'>By Nima Goudarzi (nima@javadev.org) - July, 2007&lt;br /&gt;&lt;br /&gt;This is an article about REST (Representational State Transfer) which gives you the knowledge of developing enterprise applications with SOA as a loosely coupled approach but without getting involved with SOAP and its complexities.This article consists on the following sections:&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-definitions.html"&gt;Definitions &lt;/a&gt;&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-example-authentication.html"&gt;Example: Authentication Service&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-authentication-web-service.html"&gt;Authentication Web Service &lt;/a&gt;&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-authentication-client.html"&gt;Authentication Client &lt;/a&gt;&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-xml-transformation.html"&gt;XML Transformation &lt;/a&gt;&lt;br /&gt;- &lt;a href="http://javadevs.blogspot.com/2007/07/how-to-rest-resting-without-jax-ws.html"&gt;RESTing Without JAX-WS &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;* The complete source codes and binary versions of the examples used in this article are available at: &lt;a href="http://www.javadev.org/files/rest.zip"&gt;http://www.javadev.org/files/rest.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;* This article is also available in the printable(pdf) format from the following address:&lt;br /&gt;&lt;a href="http://www.javadev.org/files/rest.pdf"&gt;http://www.javadev.org/files/rest.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-8710475034087969808?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/8710475034087969808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=8710475034087969808' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8710475034087969808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/8710475034087969808'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/how-to-rest-preface.html' title='How to REST?!'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4411999261438216170.post-1908195128125020354</id><published>2007-07-21T23:13:00.000-07:00</published><updated>2007-07-21T23:24:40.793-07:00</updated><title type='text'>Weblogic Clustering</title><content type='html'>Clustering creates an illusion — it permits the deployment of application components and services to several machines while presenting only a single face to the client. There are good reasons to support this illusion. When a client requests a service, it should make no difference if the service runs on a single server or across a number of servers. The clustering abstraction provides you with a clear route to improving the performance and scalability of your applications, albeit with increased administration of hardware and network resources. WebLogic's clustering offers three important benefits:&lt;a name="weblogictdg-CHP-14-ITERM-5361"&gt;&lt;/a&gt;&lt;a name="weblogictdg-CHP-14-ITERM-5360"&gt;&lt;/a&gt;&lt;a name="weblogictdg-CHP-14-ITERM-5359"&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;br /&gt;A solution that allows you to create additional capacity by introducing more servers to the cluster, thereby reducing the load on existing servers.&lt;br /&gt;&lt;strong&gt;Load balancing&lt;br /&gt;&lt;/strong&gt;The ability to distribute requests across all members of the cluster, according to the workload on each server.&lt;br /&gt;&lt;strong&gt;High availability&lt;br /&gt;&lt;/strong&gt;A mix of features that ensure applications and services are available even if a server or machine fails. Clients can continue to work with little or no disruption in a highly available environment. WebLogic achieves high availability using a combination of features: replication, failover, and migratable services.&lt;br /&gt;&lt;br /&gt;You can find this article at :&lt;br /&gt;&lt;a href="http://www.javadev.org/files/cluster.pdf"&gt;http://www.javadev.org/files/cluster.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4411999261438216170-1908195128125020354?l=javadevs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javadevs.blogspot.com/feeds/1908195128125020354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4411999261438216170&amp;postID=1908195128125020354' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/1908195128125020354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4411999261438216170/posts/default/1908195128125020354'/><link rel='alternate' type='text/html' href='http://javadevs.blogspot.com/2007/07/weblogic-clustering.html' title='Weblogic Clustering'/><author><name>Nima Goodarzi</name><uri>http://www.blogger.com/profile/15603619545945594317</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://4.bp.blogspot.com/-ewTwx_kgX4E/Tx-bnQo1jbI/AAAAAAAAAbQ/Rnd_lkbOifw/s220/IMG_20110910_151100.jpg'/></author><thr:total>0</thr:total></entry></feed>
