Control JAX-RS Content Negotiation with Filters

Comments Off January 18th, 2010 by Henri Bezemer

JAX-RS supports very sophisticated content negotiation, built around the HTTP accept header and the @consumes and @produces annotations. Unfortunately some (potential) RESTful clients are not so sophisticated. Try your webbrowser for instance. It is not always easy or even possible to set the HTTP accept header to the desired value. In this post I’ll present a simple Filter (javax.servlet.Filter) that dynamically adds HTTP accept headers to your requests, based on a predefined URI pattern. It has been tested with the Jersey implementation of JAX-RS. Read more…

Put JAX-RS to work with Adobe Flex

1 Comment » January 13th, 2010 by Henri Bezemer

In my previous post I’ve shown how to build a simple set of RESTful services with JAX-RS, and how to access those services from a XForms client. That example also showed the RESTful principle of HATEOAS. In this post I’ll show how to build a Adobe Flex 3 client to those services. Read more…

HATEOAS by Example

3 Comments » January 7th, 2010 by Henri Bezemer

Hypermedia as the Engine of Application State (HATEOAS) is a very useful concept in the RESTful architectural style. The best way to show the benefits of HATEOAS is by giving an example. In this post I’ll be using the Jersey JAX-RS framework to build three RESTFul services. By mixing XForms into the equation, these services form a complete (yet tiny) web application. The example can be deployed on GlassFish. Read more…

XForms backed with JAX-RS RESTful services

Comments Off December 31st, 2009 by Henri Bezemer

In an earlier post I presented a simple example of a login form implemented with XForms. In this example, XML data submitted by the form is parsed by a Java Servlet into a DOM tree, data is extracted using XPath and finally the servlet directly prints a XML result to its response stream. For large scale development, this is not the most efficient and safe way to implement this functionality.

JAX-RS allows us to efficiently build RESTful services, which are a perfect match to XForms. In this post I’ll present a JAX-RS service to replace the servlet from the login form example. Read more…

JAX-RS: At ease with REST

Comments Off December 29th, 2009 by Henri Bezemer

In this post I will create a RESTful service using the JSR 311 JAX-RS implementation called Jersey on the GlassFish application server. This service will closely match the capabilities of the typical hello world demo. The focus of this post is to show how to develop a RESTful service with JAX-RS and Maven and how to deploy it on a J2EE application server like GlassFish. Read more…

Dynamic navigation with XForms

2 Comments » December 29th, 2009 by Henri Bezemer

XForms are a great way for a Java web developer to avoid the use of the JSF framework. Instead of authoring world-wide open standard (X)HTML pages, JSF lets you code JSP pages with JSF tags. JSF forces you from a truly open standard into a less open Java only standard. This alone makes me want to avoid JSF.

XForms is a programming language independent W3C open standard. In this post I will not try to show all the benefits of using XForms. I’ll assume that you’ve already decided that you want to use XForms with Java. XForms is powerful enough to provide most if not all of the presentation logic that your web site requires. In this post I will explain how dynamic navigation can be achieved fully in XForms, thereby stripping the server side Java code of all presentation logic. Dynamic navigation is a mechanism found in the JSF framework. Put very simply, an agent (browser) posts data collected on a page to a server and the outcome of processing this data determines the next page. Read more…

Take control with WS-BPEL

1 Comment » December 11th, 2009 by Henri Bezemer

I suspect Web Service Business Process Execution Language is known to most people for the graphical designer tooling that vendors bundle with their web services suite products. My first thought when I saw this colorful click and drag tooling being demonstrated was: it looks nice, but why would someone want to code if-then-else constructs with a mouse? Is this yet another effort to bring programming to the non-programmers?

After a bit of reading up I started to recognize WS-BPEL’s true value. It is not the graphical designer tooling. In my opinion, there is simply too much XML technology that cannot be hidden from the user, to make the tooling actually usable to non-programmers. While the designer tooling is still useful, I think the true value lies in the capabilities of the WS-BPEL engine. In this post I will present a realistic working example of WS-BPEL in an ESB environment, I will explain in detail how correlation works and I will give you tons of other tips along the way. Read more…

Consuming Web Services from EJB 3 using JAX-WS

1 Comment » November 30th, 2009 by Henri Bezemer

In this post I will show how to consume a Web Service from an EJB 3 stateless session bean, with very little coding involved by leveraging the JAX-WS specification and tooling. I will add this ability to the CRM EJB that I presented in an earlier post: http://www.zienit.nl/blog/2009/11/enterprise-java/web-services-made-easy-with-ejb-jpa-and-jax-ws. I will also explain how to bundle WSDL and XML Schema files with an EAR deployment file using a catalog, how to customize the JAX-WS generated code and how to design a single Maven build process for deployment to multiple environments (development, staging and production). Read more…

Introduction

Apache ServiceMix is an Enterprise Service Bus that is compliant to the Java Business Integration specification (JBI). In a nutshell, the JBI specification defines a robust and managed environment which supports components called Binding Components (BC’s) and Service Engines (SE’s), that exchange XML messages (with optional binary attachments) with each other. The goal of a Binding Component is to convert messages to and from a specific protocol (like SOAP over HTTP) to allow communication with the outside world. The goal of a Service Engine is to provide business logic (like message transformation, message routing, or any other type of business logic). Read more…

Web services made easy with EJB, JPA and JAX-WS

Comments Off November 4th, 2009 by Henri Bezemer

In this post I will share some code and findings that came out of an experiment with EJB 3.0, JPA (included in EJB 3.0) and JAX-WS (Java API for XML-Based Web Services) 2.0. My goal was to create a useful layer of web services on top of a database with as little Java code as possible. I wasn’t sure if the three technologies could be mixed together in a thin layer without running into serious trouble, so I decided to create an example application and test it on three popular open source Java Application Servers: Geronimo (2.1.4), Sun GlassFish Enterprise Server (2.1) and JBoss (5.1.0 GA). I’m running these Application Servers on Sun JDK 6. Read more…