You are on page 1of 63

SOA using Java Web Services

Mark Hansen
Founder & President AgileIT
http://agileitinc.com
(Delete this element) If applicable, place your company logo here

Overall Presentation Goal

Learn how to build SOA Applications using JAX-WS, JAXB, and Ajax
(JAX-RS on Thursday)

www.javapolis.com

Speakers Qualifications
!

Mark Hansen is the Founder and President of AgileIT Author of SOA Using Java Web Services Developed the SOA-J Framework PhD from MITs Lab for Computer Science

www.javapolis.com

Java Web Services have greatly improved since J2EE 1.4

The Java 6 (JEE 5) Java Web Services Tools enable real SOA Application Development.

www.javapolis.com

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet WSDL, SOAP, and Java/XML Binding JAXB and JAX-WS

Break (30 minutes)

www.javapolis.com

SOA Using Java Web Services Outline (Cont)


!

Part II: Building Real Applications


! !

Code First, Contract First, and Meet in the Middle SOA Integration Case Study (eBay, Amazon, Yahoo!)

www.javapolis.com

SOA Using Java Web Services - Introduction

Am I Stupid, or Is Java Web Services Really Hard?

www.javapolis.com

SOA Using Java Web Services - Introduction

www.javapolis.com

SOA Using Java Web Services - Introduction Web Services are Hard
!

SOA = Loosely Coupled Distributed Computing with Web Services


! ! ! ! !

Concurrency Fault Tolerance Transparency Scalability Impedance Mismatch

"A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable." - Leslie Lamport

www.javapolis.com

SOA Using Java Web Services - Introduction Impedance Mismatch

www.javapolis.com

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet and JAX-WS WSDL, SOAP, and Java/XML Binding JAXB, JAX-WS

Break (30 minutes)

www.javapolis.com

SOA Using Java Web Services Part I Web Services Platform Architecture
!

Invocation
! ! !

Proxies Represent Web Services in Java Interface to Messaging System (HTTP) QoS (Handlers) Java/XML Binding Implement Web Service Endpoints (SOAP, REST) with Java
www.javapolis.com

Marshalling (Impedance Matcher)


!

Deployment
!

SOA Using Java Web Services Part I WSPA - Invocation

www.javapolis.com

SOA Using Java Web Services Part I WSPA Proxy

www.javapolis.com

SOA Using Java Web Services Part I WSPA Marshalling

www.javapolis.com

SOA Using Java Web Services Part I WSPA Deployment

www.javapolis.com

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet and JAX-WS WSDL, SOAP, and Java/XML Binding JAXB and JAX-WS JAX-RS (Under Development for Java EE 6)

Break (30 minutes)


www.javapolis.com

SOA Using Java Web Services Part I Basic REST SOAP Comparison

REST SOAP
Message Format XML1 SOAP WSDL HTTP3, FTP, MIME, JMS, SMTP, etc. Interface Definition None2 Transport
1. 2. 3.

HTTP

Also uses HTTP headers and query string. XML Schema sometimes provided. And out of band documentation. Without WS-Addressing, SOAP relies on the message transport for dispatching (e.g., HTTP context path).

www.javapolis.com

SOA Using Java Web Services Part I Basic REST HttpURLConnection (JDK 1.1)

www.javapolis.com

SOA Using Java Web Services Part I Basic REST Dispatch<Source> (JAX-WS 2.0 )

www.javapolis.com

SOA Using Java Web Services Part I Basic REST - HttpServlet

www.javapolis.com

SOA Using Java Web Services Part I Basic REST Provider<Source>

www.javapolis.com

DEMO
Basic REST HttpServlet vs. Provider<T>

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet and JAX-WS WSDL, SOAP, and Java/XML Binding JAXB and JAX-WS JAX-RS (Under Development for Java EE 6)

Break (30 minutes)


www.javapolis.com

SOA Using Java Web Services Part I The Role of WSDL in Enterprise SOA

www.javapolis.com

SOA Using Java Web Services Part I SOAP Dispatching

www.javapolis.com

SOA Using Java Web Services Part I Java/XML Binding

www.javapolis.com

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet and JAX-WS WSDL, SOAP, and Java/XML Binding JAXB and JAX-WS JAX-RS (Under Development for Java EE 6)

Break (30 minutes)


www.javapolis.com

SOA Using Java Web Services Part I JAXB Binding vs. Mapping

www.javapolis.com

SOA Using Java Web Services Part I JAXB The Standard Binding

www.javapolis.com

SOA Using Java Web Services Part I JAXB Custom Mappings with DIY Recursion

www.javapolis.com

SOA Using Java Web Services Part I JAXB Customization with XmlAdapter

www.javapolis.com

SOA Using Java Web Services Part I JAX-WS Client Side Invocation with Proxy

www.javapolis.com

SOA Using Java Web Services Part I JAX-WS WSDL to Java Binding

www.javapolis.com

SOA Using Java Web Services Part I JAX-WS Server Side Invocation Subsystem

www.javapolis.com

SOA Using Java Web Services Part I JAX-WS SOAP Fault Message

www.javapolis.com

DEMO
Examining the JAX-WS WSDL ! Invoking a Web Service
!

SOA Using Java Web Services - Outline

Intro: Am I Stupid, or Is Java Web Services Really Hard? Part I: Architecture, Concepts, Standards
! ! ! !

Web Services Platform Architecture (WSPA) Basic REST with HttpServlet WSDL, SOAP, and Java/XML Binding JAXB and JAX-WS

Break (30 minutes)

www.javapolis.com

SOA Using Java Web Services Outline (Cont)


!

Part II: Building Real Applications


! !

Code First, Contract First, and Meet in the Middle SOA Integration Case Study (eBay, Amazon, Yahoo!)

www.javapolis.com

SOA Using Java Web Services Part II Code First, Contract First, Meet in the Middle

JAX-WS Java to WSDL Standard Mapping JAXB Schema Generator

JAX-WS WSDL to Java Standard Mapping JAXB Schema Compiler

???

www.javapolis.com

SOA Using Java Web Services Part II Code First


!

The Demo before the break illustrated Code First development. Start with a Java Class and generate WSDL using JAX-WS. Modify the WSDL using Annotations.

www.javapolis.com

SOA Using Java Web Services Part II Contract First


! !

Start with WSDL and XML Schema. JAX-WS WSDL to Java Binding and JAXB provide a mapping to Java. J2SE 6 provides the wsimport tool.

www.javapolis.com

SOA Using Java Web Services Part II Meet in the Middle ! Start with WSDL and XML Schema ! AND existing Java classes. ! Two sides of the same problem:
! !

Invoke the Web services using your existing Java classes as parameters (e.g., PurchaseOrder). Deploy your existing Java classes to provide Web services that conform to the existing WSDL and XML Schema.

This is the most common scenario faced by enterprises that are implementing SOA using Java Web Services.
www.javapolis.com

SOA Using Java Web Services Part II Meet in the Middle


!

To illustrate Meet in the Middle, we look at a SOA integration case study. Step back for a few minutes to look at the architecture. Then, look at some Meet in the Middle code.

www.javapolis.com

SOA Using Java Web Services Outline (Cont)


!

Part II: Building Real Applications


! !

Code First, Contract First, and Meet in the Middle SOA Integration Case Study (eBay, Amazon, Yahoo!)

www.javapolis.com

What is AJAX?
!

! !

Asynchronous JavaScript and XML An Interaction Model A Set of Technologies for Rich Client Development ... A Composite Application Framework for Flexible Business Process Management ???

! !

Ajax In Action, Dave Crane et al., Chapter 2 pg 33


www.javapolis.com

SOA Using JWS and Ajax

www.javapolis.com

SOAShopper Architecture

www.javapolis.com

eBay WSDL

www.javapolis.com

Ant Task to Compile eBay WSDL

www.javapolis.com

Using the Generated eBay API

www.javapolis.com

A Client Binding Example


public List<Offer> offerSearch( String keywords, Category category, Price lowprice, Price highprice) {

ShopperImp binding = BindingService.getBinding( ShopperImp.class, EBayAPIInterface.class);

return binding.offerSearch(keywords, category, lowprice, highprice); }

www.javapolis.com

Meet in the Middle Service Integration Bridge

www.javapolis.com

Meet in the Middle Object Integration Bridge

www.javapolis.com

Implementing a Binding Service

public abstract class BindingService { public static <C> C getBinding( Class<C> client, Class<?> service) { ... } }

www.javapolis.com

Demo
SOAShopper Integrating Yahoo!, Amazon, and eBay

Flash Demo

www.javapolis.com

Using the Dojo Table Widget

<table dojoType="filteringTable" id="fromSOAShopperData" multiple="true" alternateRows="true" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:24px;"> <thead> <tr> <th field="source" dataType="String">Source</th> <th field="thumbnail" dataType="html" align="center">Image</th> <th field="price" dataType="String">Price</th> <th field="summary" dataType="String">Summary</th> <th field="url" dataType="html">Link</th> </tr> </thead> </table>

www.javapolis.com

Invoking the REST Endpoint


function retrieveURL(url) { restURL = url; showSearchingMsg(restURL); if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = processStateChange; try { req.open("GET", url, true); req.setRequestHeader('Content-type','text/xml'); } catch (e) { alert(e); } req.send(null); } else if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); ... } }
www.javapolis.com

Loading the Dojo Table

function populateTableFromLiveSOAShopperData() { try { var w = dojo.widget.byId ("fromSOAShopperData"); w.store.setData(theSOAShopperLiveData); } catch(e) { alert(e); } }


www.javapolis.com

Summary
! ! ! !

Summary point one Summary point two Summary point three Summary point

Instructions: (Delete this element)

This is where the END portion of the presentation starts. Summarize all of the key content points covered in your presentation.

www.javapolis.com

Concluding statement

Insert concluding statement or quote here. Remember, this is the final take-away that will challenge your audience with a call to action.
Instructions: (Delete this element)

This is the time to challenge your audience with a call to action. What would you like them to think, do, or feel as a result of attending your presentation?

www.javapolis.com

Q&A
View JavaPolis talks @ www.parleys.com

You might also like