RESTful Services with JAX-RS, JQuery Bonus Content: JSF 2.0<br />Jeffrey West<br />Application Grid Product Management<br />
Questions & Discussion<br />
<Insert Picture Here><br />Program Agenda<br />JAX-RS / JQuery<br />JAX-RS Introduction & Overview<br />JAX-RS vs SOAP<br ...
JAX-RS(Jersey) Programming Model<br />Stub<br />Resource<br />JAX-RS  API<br />JAX-RS  API<br />Server Side<br />Runtime S...
REST – Representational State Transfer<br />JSR-311: JAX-RS<br />Exposes named RESOURCES which represent DATA<br />Resourc...
@Path
@Produces/Consumes
@HEAD/PathParam/QueryParam
@GET/POST/PUT/DELETE</li></li></ul><li>WADL - Example<br /><?xml version="1.0" encoding="UTF-8" standalone="yes"?><br /><a...
Example (Resource class)<br /> @Path("widgets")@Produces("application/xml, application/json")public class WidgetsResource ...
REST vs. SOAP<br />
SOAP – Simple Object Access Protocol<br />Exposes OPERATIONS that implement/represent LOGIC<br />Provides loose coupling f...
REST vs. SOAP<br />REST<br />Exposes RESOURCES which represent DATA<br />Uses HTTP Verbs (GET/POST/DELETE)<br />Emphasis o...
REST is better than SOAP!<br />REST can be consumed by any client, even a web browser with Ajax and Javascript<br />REST i...
SOAP is better than REST!<br />Building a client for REST can be challenging<br />I can easily generate client-side artifa...
Both SOAP and REST have their rightful places<br />REST<br />Good for:<br />Web Services<br />Limited bandwidth (smaller m...
Oracle Parcel Service<br />
Oracle Parcel Service<br />
Upcoming SlideShare
Loading in...5
×

WebLogic Developer Webcast 4: RESTful Services with JAX-RS, JQuery and JSF 2.0

4,663

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,663
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
92
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Jersey is the reference implementation of JAX-RS and is the implementation that you will find in both WebLogic Server and GlassFish. Lets take a look at the programming model.First, if you stick with the best practices and the standard approach to REST you will create ‘services’ out of ‘resources’. At runtime, you will be able to generate a WADL which specifies the URIs and supported HTTP methods/verbs (GET, PUT, POST, DELETE) and you can use this to create client-side applications. The JAX-RS specification only provides details for server-side APIs but if you use Jersey then you can take advantage of the classes that it offers to consume REST services.Just like SOAP, the container will take care of mapping your data representation, whether it is in XML or JSON, to your Java POJOs. In addition, JAX-RS takes care of HTTP handshaking and allows you to perform content negotiation at runtime. Also, JAX-RS supports HTTP communication ONLY. There are no other transports supported.
  • Evolution over XML-RPCAllowed you to get around firewalls with HTTPSimply put, a format for sending messages
  • Lets take a look at the arguments that claim REST is better than SOAP.First, RESTful services are lightweight can be consumed by a wide variety of clients – from standalone Java applications to simple browser-based applications using JavascriptREST doesn’t require XML parsing so the CPU requirements are lower than SOAP and REST doesn’t require a SOAP envelope so the messages consume less bandwidthAnother argument is that SOAP is old and all of the ‘new’ or ‘cool’ sites on the internet use REST, and this is very true for many consumer-facing websites and web service providers.In addition, you can learn how to use REST very easily. Its just nouns and verbs – resources and HTTP methods. I don’t have to learn XML and SOAP just to interact with a service producerPlus, REST is safe. I can simply enable passthrough on HTTP GET’s and spend my effort looking at PUTs and DELETEs.
  • Both SOAP and REST have their rightful place within enterprise and consumer applications, and there is no reason they can’t co-exist and support the same enterprise application. REST is ideally suited for exposing data over the internet (or networks in general) and has low bandwidth and CPU requirements. It’s also good for creating mashups of different content from various providers on a web page.However, if you look at the enterprise requirements for messaging, you may find that SOAP is a better fit because it offers enterprise features like High Reliability with WS-RM
  • WebLogic Developer Webcast 4: RESTful Services with JAX-RS, JQuery and JSF 2.0

    1. 1.
    2. 2. RESTful Services with JAX-RS, JQuery Bonus Content: JSF 2.0<br />Jeffrey West<br />Application Grid Product Management<br />
    3. 3. Questions & Discussion<br />
    4. 4. <Insert Picture Here><br />Program Agenda<br />JAX-RS / JQuery<br />JAX-RS Introduction & Overview<br />JAX-RS vs SOAP<br />JAX-RS WebLogic Configuration<br />JAX-RS Code Review<br />JQuery Application Demo<br />JQuery Code Review<br />JSF 2.0<br />JSF 2.0 Application Demo<br />JSF 2.0 Code Review<br />
    5. 5. JAX-RS(Jersey) Programming Model<br />Stub<br />Resource<br />JAX-RS API<br />JAX-RS API<br />Server Side<br />Runtime System<br />Client side<br />Runtime System<br />Protocol (REST/HTTP)<br />Transport<br />WADL<br />Service Client<br />Service Endpoint<br />Container<br />WADL<->Java Mapping<br />Dispatch<br />
    6. 6. REST – Representational State Transfer<br />JSR-311: JAX-RS<br />Exposes named RESOURCES which represent DATA<br />Resource: POJO<br />URI path template<br />ID<br />Uses simple Nouns (Resources) and verbs (HTTP Methods)<br />GET/PUT/POST/DELETE<br />Emphasis on simple, stateless point-to-point communication over HTTP<br />Supports multiple data formats<br />JSON/XML/TEXT/XHTML<br />Runtime Content Negotiation<br /><ul><li>Annotation-driven
    7. 7. @Path
    8. 8. @Produces/Consumes
    9. 9. @HEAD/PathParam/QueryParam
    10. 10. @GET/POST/PUT/DELETE</li></li></ul><li>WADL - Example<br /><?xml version="1.0" encoding="UTF-8" standalone="yes"?><br /><application xmlns="http://research.sun.com/wadl/2006/10"><br /> <doc xmlns:jersey="http://jersey.dev.java.net/" <br />jersey:generatedBy="Jersey: 1.1.2-ea-SNAPSHOT 07/28/2009 04:05 PM"/><br /> <resources base="http://localhost:7001/HelloRS"><br /> <resource path="/helloworld"><br /> <method name="GET" id="getClichedMessage"><br /> <response><br /> <representation mediaType="text/plain"/><br /> </response><br /> </method><br /> </resource><br /> </resources><br /></application><br />WADL URL: http://host:port/root_context/application_path/application.wadl<br />
    11. 11. Example (Resource class)<br /> @Path("widgets")@Produces("application/xml, application/json")public class WidgetsResource {@GETpublic WidgetsRepresentationgetWidgetList() { ... }@GET @Path("{id}") public WidgetRespresentationgetWidget(@PathParam("id") String widgetId) { ... }}<br />
    12. 12. REST vs. SOAP<br />
    13. 13. SOAP – Simple Object Access Protocol<br />Exposes OPERATIONS that implement/represent LOGIC<br />Provides loose coupling for integrating diverse systems<br />Designed for distributed computing<br />Designed to be extensible – WS-*<br />Standard error messaging – SOAP faults with standard Code/Subcode for error types<br />Aligns with Enterprise Application needs and goals<br />Supports other transport protocols than HTTP – SMTP, JMS<br />Supports enterprise security with WS-Security<br />Supports language neutrality<br />Supports ACID, Atomic transactions with WS-AT<br />Supports Reliable Messaging with WS-RM<br />Easy governance with strong typing<br />Broad Development Tools support <br />
    14. 14. REST vs. SOAP<br />REST<br />Exposes RESOURCES which represent DATA<br />Uses HTTP Verbs (GET/POST/DELETE)<br />Emphasis on simple point-to-point communication over HTTP<br />Supports multiple data formats<br />Emphasizes stateless communication<br />SOAP<br />Exposes OPERATIONS which represent LOGIC<br />Uses HTTP POST<br />Emphasis on loosely coupled distributed messaging<br />Supports only XML (and attachments)<br />Supports stateless and stateful/conversational operations<br />Supports asynchronous messaging<br />Strong Typing<br />
    15. 15. REST is better than SOAP!<br />REST can be consumed by any client, even a web browser with Ajax and Javascript<br />REST is lightweight<br />REST doesn’t require XML parsing<br />REST consumes less bandwidth – doesn’t require a SOAP header for every message<br />SOAP is OLD! All the ‘cool kids’ are using REST!<br />Twitter, Google, Flickr<br />I can learn to use REST very quickly<br />It’s just nouns and verbs, how hard can it be?<br />REST is SAFE!<br />Aren’t all ‘GET’ operations safe?<br />
    16. 16. SOAP is better than REST!<br />Building a client for REST can be challenging<br />I can easily generate client-side artifacts from a WSDL<br />I don’t want to write raw HTTP calls<br />I don’t want to look at the HTTP response code for success/failure – I want to use my own exception types and codes<br />Many IDE’s support SOAP development – both client and server<br />REST only supports HTTP/HTTPS<br />HTTP is synchronous and in order to scale I need to be able to have asynchronous messaging<br />REST is not secure<br />Parameters as part of the URI<br />No support for acquiring tokens<br />RESTful services have no contract<br />I have a WADL that specifies URL’s but what about schemas for object definition<br />REST is not reliable<br />I have to handle failures with retries – no Reliable Messaging<br />REST can’t be governed<br />How do I know who is consuming my services without a Service Registry?<br />How do I discover RESTful services?<br />
    17. 17. Both SOAP and REST have their rightful places<br />REST<br />Good for:<br />Web Services<br />Limited bandwidth (smaller message size)<br />Limited resources (no xml parsing required) <br />Exposing data over the Internet<br />Combining content from many different sources in a web browser<br />SOAP<br />Good for:<br />Enterprise services<br />High Reliability with WS-RM<br />Transactions with WS-AT<br />Security with WS-Security<br />Asynchronous processing<br />Contract-first development<br />Stateful /conversational operations<br />Standards support, interoperability with business applications<br />Tooling Support<br />
    18. 18. Oracle Parcel Service<br />
    19. 19. Oracle Parcel Service<br />
    20. 20. JQuery<br />Client Side JavaScript designed to simplify JavaScript and create powerful & dynamic websites<br />Eases the:<br />Navigation of HTML documents<br />Queries to select DOM elements<br />Creation of Animations<br />Handling of Events<br />Development of AJAX based applications (which are aligned with consuming RESTful services)<br />JQuery is one of the most popular JavaScript libraries uses today: http://trends.builtwith.com/javascript/JQuery<br />Free, open-source MIT- and GNU-licensed<br />
    21. 21. JSF 2.0<br />Great Blog Post: http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/#ajax<br />Annotation-Driven<br />Managed Bean Annotations<br />Converter Annotations<br />Composite Components<br />Not required: UIComponent, Renderer, faces-config.xml<br />Ajax support<br />Navigation<br />Implicit Navigation<br />Conditional Navigation<br />Project Stage:<br />‘Development’ provides more detailed error messaging (not just HTTP 500)<br />Resource Libraries Loading<br />‘Libraries’ for CSS, Images, Etc<br />
    22. 22. PrimeFaces – www.primefaces.org<br />“PrimeFaces is a lightweight open source component suite for Java Server Faces 2.0 featuring 100+ rich set of JSF components”<br />Easy to use, good looking components<br />Multiple themes<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×