YOUR FEEDBACK
andy.mulholland wrote: intriguing !!! We have full scale 'Mashup Factories' in Chicago USA and Utrec...
AJAXWorld RIA Conference
Early Bird Savings Expire Friday Register Today and SAVE !..

READ DIGITAL EDITION


SYS-CON.TV

2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
TOP THREE LINKS YOU MUST CLICK ON


Constructing Services with SOA & Open Source Java
The Jedi mind trick is a Force power that can influence the actions of weak-minded sentient beings

Typically, a real-world application will have a database running for these Hibernate tools tasks to reverse-engineer against. The example code uses a HSQL database engine to simulate this behavior. The source code to start-up, create, and populate the database can be found in the example application.

The data access service is defined in our Spring context file in Listing 4.

The database consists of one table called ANDROID that's mapped to a Java class called Android. The generated data access object can then be used in our data access provisioning service:

public class ProvisioningDaoImpl extends AbstractDao implements ProvisioningDao {

    public Android findDroid(String id) {
       return (Android) load(Android.class, id);
    }
}

public abstract class AbstractDao {

    public Object load(Class clazz, Serializable id) {
       return this.sessionFactory.getCurrentSession().load(clazz, id);
    }
}

The configuration needed for Hibernate is performed behind the scenes using Spring.

WSDL-First, You Must Do
Vader is getting impatient. He still can't access his TPS reports since there's no external API. We can expose our data access service with a Web Service using a simple framework called XFire. Let's examine the steps to enable simple top-down Web Service creation.

WSDL-first development is the concept of writing the interface for your Web Service before you write the code. WSDL-first development makes sense because it focuses less on a particular programming language and more on the messages between systems. Many people take the approach of generating the WSDL from existing code whether it's an EJB, POJO, or some other programming construct. WSDL-first takes a more top-down approach wherein the schema and WSDL are designed first and code generation happens from there. XML Schema is language-independent and provides more flexibility than a lot of programming languages. Client code, interfaces, implementation code, and schema types can all be generated from a WSDL and schema by a number of SOAP stack frameworks. One of the main benefits of WSDL-first development is improving interoperability between disparate systems programmed in different languages.

Taking our top-down approach let's look at an operation defined on our WSDL:

<wsdl:operation name="findDroid">
   <soap:operation style="document" soapAction="findDroid"/>
   <wsdl:input><soap:body use="literal"/></wsdl:input>
   <wsdl:output><soap:body use="literal"/></wsdl:output>
</wsdl:operation>

The document/literal approach to constructing a Web Service is more straightforward and solves many interoperability issues since it simply relies on XML Schema to describe exactly what the message looks like when delivered. Also, document/literal is WS-I (Web Services Interoperability) compliant. The request and response messages are defined below:

<xs:element name="findDroid" type="provisioning:findDroid"/>
<xs:complexType name="findDroid">
       ...
</xs:complexType>
<xs:element name="findDroidResponse" type="provisioning:findDroidResponse"/>
<xs:complexType name="findDroidResponse">
       ...
</xs:complexType>

By using a combination of XMLBeans (one of the many XML binding mechanisms supported by XFire), XFire, and our WSDL we can use separate tasks in Maven to generate everything needed to build a Web Service. There's an execution step defined in our maven-antrun-plugin in Listing 5.

All of the Web Service code generation is done in the generate-sources phase of the Maven build lifecycle. This lets us generate all of the messaging objects we rely on before our implementation code needs to compile against them. Since all of our messaging objects have been generated we can now implement our provisioning Web Service. XFire creates an implementation class based on the WSDL provided. That same class will be used to implement all of the business logic needed by our system.

The provisioning service is injected with the core service and data access service defined and implemented in earlier modules. The code in Listing 6 shows the provisioning service using the two services it's dependent on to look up android information.

The only thing left to do is wire up our provisioning Web Service. An important thing to note is that the provisioning service is a POJO. We could easily inject it into a different transport protocol implementation. XFire is used in this instance. We define our provisioning service as a service bean in XFire's service factory and are off and running.

<serviceFactory>org.codehaus.xfire.xmlbeans.XmlBeansServiceFactory</serviceFactory>
    <serviceBean>#provisioningServiceImpl</serviceBean>
</service>

<bean id="provisioningServiceImpl" class="com.examples.droid.ws.provisioning.ProvisioningServiceImpl">
    <property name="coreService" ref="coreService"/>
    <property name="provisioningDao" ref="provisioningDaoImpl"/>
</bean>

XFire takes care of the Web servlet, marshaling/unmarshaling of the SOAP messages, and determining which service and which operation needs to be executed. If our requirements dictate that we need a composite service comprised of the provisioning service and some other service we could just create a higher-level module and inject the services that have already been built. The provisioning service would then be just a POJO as opposed to a formal Web Service.

Empire Building
The example demonstrates how Maven can be leveraged to create an entire framework that developers can work in. If the infrastructure is set up properly developers can leverage and reuse many tasks through project inheritance and common plug-ins. Consistency goes a long way in creating large enterprise applications. Adopting a "convention over configuration" approach will let developers build a general framework that will scale to large projects.

The Saga Continues
I encourage you to dive deeper into the Maven application management tool and think about how it can really drive and enable a more modular service-based vision for your architecture. I also encourage you to look into using Maven with the other open source frameworks listed in this article. The build system is truly a reflection of your application's health in terms of maintainability and the ability to bolt on new modules in a timely manner. This article demonstrated at a conceptual level how many different open source frameworks could be glued together to create an extremely flexible layered architecture able to expose modules as services. These services can be reused in other parts of an application by merely injecting them into horizontal or upstream modules.

Acknowledgements
I would like to thank Steve Meyer and Chris Swift for invaluable editing comments and ideas.

References
• Cargo: http://cargo.codehaus.org/
• Dependency Injection: www.martinfowler.com/articles/injection.html
• Hibernate: www.hibernate.org/
• Maven: http://maven.apache.org/
• Spring: www.springframework.org/
• Star Wars: http://en.wikipedia.org/wiki/Star_Wars
• XMLBeans: http://xmlbeans.apache.org/
• XFire: http://xfire.codehaus.org/

About Franz Garsombke
Franz Garsombke has been developing and architecting enterprise software solutions in Colorado for the last eleven years and is currently employed at Rally Software. Franz is a huge proponent of open source frameworks and is passionate about developing and delivering simple, quality, pragmatic applications. He is proud to be the co-founder of a Java Bean mapping framework (http://dozer.sourceforge.net) and can be reached at fgarsombke@yahoo.com or on his mountain bike.

WIRELESS BUSINESS & TECHNOLOGY LATEST STORIES . . .
In the 2-day iPhone Developer Summit, delegates will hear from industry experts about the impact the iPhone is having on delivery of rich content to mobile users. Technical sessions will explore a world of web development opportunities on the iPhone including building applications usin...
As the mobile web matures, we see more and more people running around airports with their mobile devices in hand, searching for hotel rooms, reading the news, or just playing video games. People are more connected with their mobile phone today than any other electronic device they use....
Sybase iAnywhere has launched its new Nokia Intellisync Migration Program. The program is aimed at supporting Nokia Intellisync partners and customers affected by Nokia’s decision to stop the development and marketing of its behind-the-firewall business mobility solutions. Sybase iAn...
From the press some of the initial iPhone apps have been getting, it seems that there are going to be quite a few Apple iPhone App Store millionaires this year! So why not write your own and join the crowd? Don't know Objective C or XCode - then get learning! A nice resource is theipho...
Rich Internet Applications offer the potential to fundamentally change the user experience and in doing so, yield significant business benefits. The theme of this October's AJAX World Conference & Expo 2008 West is 'Beyond AJAX to the RIA Era' and the Call for Papers, which is still op...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE