Académique Documents
Professionnel Documents
Culture Documents
Mark Hansen
Founder & President
AgileIT
http://agileitinc.com
http://agileitinc.com
Speakers Qualifications
JAXB
JAX-RS
http://agileitinc.com
Outline
http://agileitinc.com
http://agileitinc.com
http://agileitinc.com
creates an
.
Impedance Mismatch
http://agileitinc.com
Impedance Mismatch
Java Objects
Java Objects
Impedance Matcher
(Object Relational
Mapping)
Impedance Matcher
(Java/XML Binding)
Relational Tables
XML Documents
Table
Table
XML
Table
XML
XML
http://agileitinc.com
Invocation
Deployment
Invocation
param
return
param
param
Invocation Subsystem
(Server Side)
Java Method
Invocation
Request :
SOAP
Request :
SOAP
param
param
Response :
SOAP
Response :
SOAP
param
Invocation Subsystem
(Client Side)
return
SOAP Message
Exchange
(Specified by WSDL)
http://agileitinc.com
Java Method
Invocation
Target :
Java Object
http://agileitinc.com
http://agileitinc.com
Deployment
Web Services Platform
Web Services Directory
(e.g., UDDI)
Container (e.g., J5EE,
Servlets, Axis)
WSDL
+someOperation()
Endpoint Listener
-url
WSDL
Deployment
WSDL/Java
Mapping
SOAP
Handlers
Java Target
Binding
Context
Container
Deployment
Descriptors
+someMethod()
http://agileitinc.com
Source Artifacts
(e.g., EJB wrapper)
REST SOAP
Message Format
XML1
SOAP
WSDL
Transport
1.
2.
3.
HTTP
http://agileitinc.com
http://agileitinc.com
Code Examples
Implementing REST Services
HttpServlet vs. JAX-WS vs. JAX-RS
Sender
XML Message
GetNewOrders
URL
openConnection(...)
1
HttpURLConnection
InputStream
HTTP response
containing XML
document
read(...)
3
connect(...)
2
Client
HTTP "GET"
request to
download XML
document
Web Service
http://agileitinc.com
Sender
XML Message
GetNewOrders
Service
1
addPort(...)
createDispatch(...)
2
Dispatch<Source>
3
invoke(...)
5
Source
Client
HTTP response
containing XML
document
Web Service
http://agileitinc.com
Sender
XML
Message
GetNewOrdersServlet
(extends HTTPServlet)
2
doGet( ... )
getNewOrders( ... )
3
Source
6
HTTP response
containing the XML
new orders
document
( new orders )
Tranformer
transform( )
StreamResult
ServletOutputStream
Client
OrderManager
Servlet Container
http://agileitinc.com
XML
Message
Sender
GetNewOrdersProvider
(Provider<Source>)
2
invoke( ... )
OrderManager
getNewOrders( ... )
3
Source
Client
HTTP response
containing the XML
new orders document
5
( new orders )
Java EE 5 Container
http://agileitinc.com
XML
Message
Sender
@Path("/orders")
HTTP GET request
1
@ProduceMime("text/xml")
@GET
2
getNewOrders()
Client
HTTP response
containing the XML
new orders document
5
Java EE 6 Container
http://agileitinc.com
Database
subsystem
Enterprise System
(e.g., Order Management System)
ServiceDeployment
subsystem
datatype
types
datatype
binding
subsystem
subsystem
http://agileitinc.com
operation
Java Method
JAXB
types
portType
JAX-WS
Service Endpoint
Implementation (SEI)
operation
+ method()
http://agileitinc.com
WSDL
WSDL
WSDL
Java
Java
Java
Code First
Contract First
Meet in the
Middle
http://agileitinc.com
Code First
Generate WSDL.
Translate SOAP request to a Java method
invocation.
Translate method return into a SOAP
response.
http://agileitinc.com
WSDL to Java
Mapping Tool
WSDL
(e.g., wsimport)
Endpoint URL
javax.xml.ws.Service
4
getPort(...)
SOAP
Request
Proxy Instance
Parameters
(JAXB Generated
Class Instances)
Service
Endpoint
Interface
Invocation
Handler
Return Value
(JAXB Generated
Class Instance)
http://agileitinc.com
SOAP
Response
DEMO
Code First With JAX-WS
Contract First
Publish
WSDL
JSR-109 &
JSR-181
Services
Handler Chain
Web Service
7
Handler
(javax.xml.ws.handler
.soap.SOAPHandler)
SOAP
Response
mustUnderstand
Processing
3
Dispatcher
SOAP
Request
Endpoint Listener
Get WSDL
http://agileitinc.com
@WebService or
@WebServiceProvider
SEI
Meta-Data
Other
Implementation
Classes
(e.g., mapped
from WSDL or
user defined)
(e.g., WSDL,
Handler File,
Deployment
Descriptors)
DEMO
Contract First
With JAX-WS
http://agileitinc.com
http://agileitinc.com
Java
<xs:schema ...
elementFormDefault="qualified"
targetNamespace="http://www.example.com/corp">
<xs:complexType name="AddressType">
<xs:sequence>
<xs:element name="addrLine1" type="xs:string"/>
<xs:element name="addrLine2" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:string"/>
<xs:element name="phone" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
private
private
private
private
private
private
...
int streetNum;
String streetName;
String city;
State state;
int zip;
Phone phoneNumber;
http://agileitinc.com
Class Bar2
<complexType name=X>
...
<sequence>
<element name= E1
type=ns:Y/>
...
</sequence>
...
<attribute name=A2"
type=ns:Z/>
...
</complexType>
Property P1
(2) Serialize P2 to an
attribute A2 of type ns:Z
using Serializer for <Z, Bar2>
Property P2
recursive
serialization
Class Bar1
...
...
<complexType name=Y>
...
</complexType>
recursive
serialization
http://agileitinc.com
AddressAdapter
(XmlAdapter)
1
AddressXML
String
String
String
State
int
Phone
addrLine1;
addrLine2;
city;
state;
zip;
phone;
IntToStringAdapter
(XmlAdapter)
2
String
Phone
int
areaCode;
String exchange;
String number;
PhoneAdapter
(XmlAdapter)
3
<xs:complexType name="AddressType">
<xs:sequence>
<xs:element name="addrLine1"
type="xs:string"/>
<xs:element name="addrLine2"
type="xs:string"/>
<xs:element name="city"
type="xs:string"/>
<xs:element name="state"
type="xs:string"/>
<xs:element name="zip"
type="xs:string"/>
<xs:element name="phone"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
String
http://agileitinc.com
http://agileitinc.com
Servlets/JSPs Struts
JAX-WS/JAXB ??? JWS Framework ???
A JWS Framework should provide two
capabilities:
Adapter Bindings
Endpoint Mirroring
http://agileitinc.com
Supplier1
Web Service
Supplier2
Web Service
PO1
Map1
PO2
Map2
Supplier2
Web Service
PO3
Map3
PO
http://agileitinc.com
Adapter Binding
WSDL
Adapter
Binding
Java
Meet in the
Middle
http://agileitinc.com
Endpoint Mirroring
SOAP
@WebService
Purchasing
Invoker
Production
Purchasing
http://agileitinc.com
DEMO
ServiceLayerTM
Java-WS Framework
Ongoing Research
mark@agileitinc.com
http://agileitinc.com
Q&A
http://agileitinc.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 ???
http://agileitinc.com
7
4
showSearchingMsg()
(JavaScript Function)
2
processStateChange()
(JavaScript Function)
8
setData()
(Dojo FilteredTable
Function)
9
XML/
HTTP
Internet
5
REST Services
@WebServiceProvider
Provider<Source>
SOAShopper Standard
XML Schema
6
SOAShopper
Internals
eBay API
(SOAP)
Amazon API
(SOAP)
Yahoo API
(REST)
http://agileitinc.com
Internet
Java EE 5 Container
eBay Web
Services
Amazon Web
Service
Yahoo Shopping
Web Services
SOAShopper Architecture
Web Browser
(AJAX)
REST based
Consumer
WSDL/SOAP
based Consumer
POX
SOAP
Internet
Java EE 5 Container
WSDL
SOAShopper Standard
XML Schema
REST Endpoint
Binding REST Services
Provider<Source>
REST
Endpoint
@WebService
Provider
SOAShopper API
@WebService
SOAP
Endpoint
eBay Client
Binding
(SOAP)
eBay Web
Services
Amazon
Client
Binding
(SOAP)
Amazon Web
Service
Internet
SOAP Endpoint
Binding SOAP Services
Yahoo Client
Binding
(REST)
http://agileitinc.com
Yahoo
Shopping
Web Services
eBay WSDL
http://agileitinc.com
http://agileitinc.com
http://agileitinc.com
eBay Client
Binding
return
binding.offerSearch(keywords,
category, lowprice, highprice);
Internet
}
http://agileitinc.com
Shopper
+offerSearch()
ComputerShopper
-imp
ShopperImp
+offerSearch()
CellphoneShopper
EBayShopperImp
AmazonShopperImp
eBay
Model
-port
EBayAPIInterface
Amazon
Model
Yahoo
Model
-port
-port
AWSECommerceService
http://agileitinc.com
YahooShopperImp
YahooRESTInterface
Offer
-imp
+getSource()
+getThumbnail()
+getPrice()
+getSummary()
+getMerchantName()
ComputerOffer
CellphoneOffer
+getDiskSize()
+getNetwork()
EBayOfferImp
eBay
Model
-port
EBayAPIInterface
OfferImp
+isAuction()
+minimumToBid()
AmazonOfferImp
YahooOfferImp
Amazon
Model
Yahoo
Model
-port
-port
AWSECommerceService
http://agileitinc.com
YahooRESTInterface
http://agileitinc.com
Demo
SOAShopper Integrating Yahoo!,
Amazon, and eBay
Flash Demo
http://agileitinc.com
http://agileitinc.com
http://agileitinc.com
function populateTableFromLiveSOAShopperData()
{
try {
var w =
dojo.widget.byId("fromSOAShopperData");
w.store.setData(theSOAShopperLiveData);
} catch(e) {
alert(e);
}
}
http://agileitinc.com