LarryRoth.net

Just my thoughts

Web services in Java 6

Eyal Lupu has a nice (short) primer on Web service support in Java 6. It's an easy read, and it really gets you excited about the possibilities of Web services. Since the concept of Web services was first mentioned, it seemed like an ideal way to foster code reuse and componentization (in the Web domain)—ideas that are core to Java development.

However, in the Java space, there has always been a fairly steep learning curve and/or a significant amount of code and configuration that went along with using Web services. But now, thanks to the power of annotations and Sun listening to the Java community, it is now quite simple.

Here is a before and after snippet. See if you can spot the difference:
Before

package ws;
public class CalcWS {
   public int add(int a, int b) {
     return a+b;
   }
   public float div (int a, int b) {
     return a/b;
   }
}
After (from the article)
package ws;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class CalcWS {
   public int add(int a, int b) {
     return a+b;
   }
   public float div (int a, int b) {
     return a/b;
   }
}

See the difference? Just 4 lines of code two imports and two annotations. Pretty cool! Now if we can just get Tor Norbye to abandon Creator and Project Semplice and focus on enabling the following annotation:
@TurnThisObjectIntoACoolWebAppLikeRailsDoes
That's not too much to ask, is it?

blog comments powered by Disqus