Designing and Building a Real-World Service Oriented
Document Sample


DESIGNING AND BUILDING A REAL
WORLD
SERVICE ORIENTED ARCHITECTURE
Eben Hewitt, Principal Programmer, SOA Team, DTC
BOF5433
Consider how you can adopt SOA by learning
how we implemented ours.
2008 JavaOneSM Conference | java.com.sun/javaone | 2
Agenda
Background
Our Approach to SOA
Tools and APIs
Lessons Learned
2008 JavaOneSM Conference | java.com.sun/javaone | 3
My Background
10 years Java programming
SOA Team at $2.5B retailer
5 books
• 3 on Java including upcoming
SOA Cookbook (O’Reilly)
2008 JavaOneSM Conference | java.com.sun/javaone | 4
Company Context
Current Distribution
• 2,800 Swing POS clients
• IBM midranges (store and central)
• 50 years of legacy code, including custom financials
• 70,000 invoices/day
• 100,000+ customer inquiries/day
Tires.com
• 100,000 unique visits/day
Wholesale Business
Hundreds of vendors
“Best tool for the job” attitude
2008 JavaOneSM Conference | java.com.sun/javaone | 5
It’s SOA, not SOD
2008 JavaOneSM Conference | java.com.sun/javaone | 6
What is SOA?
“SOA is a kind of architecture...
that uses services as building blocks
to facilitate enterprise integration
and component reuse
through loose coupling.”
2008 JavaOneSM Conference | java.com.sun/javaone | 7
A Code Puzzle
Without having to know Java, which code is better?
This:
aFrame.getPanelA().getWidgetX().setText("Hi");
or this:
aFrame.setWelcomeText("Hi");
2008 JavaOneSM Conference | java.com.sun/javaone | 8
Our Goals for SOA
Leverage existing assets & extend their life
• Some code in production 18 years
• Custom GL
Freedom
Reduce time-to-market
• New products
• Compliance
Reduce complexity
Clarity, Maintainability
2008 JavaOneSM Conference | java.com.sun/javaone | 9
Agenda
Background
Our Approach to SOA
Tools and API s
Lessons Learned
2008 JavaOneSM Conference | java.com.sun/javaone | 10
Our Approach to SOA
Start with well-defined business initiatives and outcomes
Deliver architecture and pilot services concurrently
Integrate, Communicate, Educate
2008 JavaOneSM Conference | java.com.sun/javaone | 11
Our Strategy
Central Team (CoE)
Pilot Project
• QuickScreen Credit Card approvals
SOA Team Does Full Round-Trip
• Produce and Consume/Integrate
• Service, Orchestration, ESB
Incubate Reference Architecture & Services concurrently
Educate & Evangelize Concurrently
• Ref Arch Site & Blog
2008 JavaOneSM Conference | java.com.sun/javaone | 12
3 Year Plan
2008 JavaOneSM Conference | java.com.sun/javaone | 13
Selecting a Pilot
Does it create business value?
Does it have limited scope?
Would it make a good service?
Is it useful but not mission critical?
QuickScreen...
2008 JavaOneSM Conference | java.com.sun/javaone | 14
Service Types
Entity
• Customer
Functional/Utility
• Email
• Exception Hospital
Process
• Apply for Credit
2008 JavaOneSM Conference | java.com.sun/javaone | 15
Our SOA Tools
Java SE 6 and Java EE 5
• JAX-WS 2.1 APIs built in
• No JAX-RPC
GlassFish v2
OpenESB
NetBeans 6 and Eclipse
Easy exit strategy
2008 JavaOneSM Conference | java.com.sun/javaone | 16
What We Did: SOAP & WSDL
Wide industry support
JAX-WS makes it easier
Want strong interface
• EJB only is Java-specific
Want free add-on standards support
• RM, AT, Addressing
Not crazy about REST
• Don’t get related standards
• Though WADL and JSR 311 may have some impact
2008 JavaOneSM Conference | java.com.sun/javaone | 17
What We Did: ESB
Performs Routing, Transformation, Orchestration,
Mediation
• Services exposed as WSDL
Acts as broker
• All interaction is bus-to-bus
• One Logical Bus per business unit
• Can expand into Regional Buses
Two ESBs
• Data Services (common)
• Payment ESB (PCI)
Can be a product or patterns
2008 JavaOneSM Conference | java.com.sun/javaone | 18
Why OpenESB?
Integration with Glassfish
JBI for NMR regardless of protocol
BPEL engine
Free & Open Source
2008 JavaOneSM Conference | java.com.sun/javaone | 19
Infrastructure
2008 JavaOneSM Conference | java.com.sun/javaone | 20
Agenda
Background
Our Approach to SOA
Tools and APIs
Lessons Learned
2008 JavaOneSM Conference | java.com.sun/javaone | 21
APIs
2008 JavaOneSM Conference | java.com.sun/javaone | 22
What is WSIT/Metro?
2008 JavaOneSM Conference | java.com.sun/javaone | 23
Determine a Start-From Model
Consider Service Elicitation Models
• Top Down/Bottom up
Java, WSDL, Java and WSDL, Schema
If you’re new to it, can start from Java then move to WSDL
2008 JavaOneSM Conference | java.com.sun/javaone | 24
Schemas: Our “Start-from” Data Model
XML-Centric
• Business Document entities
Start-from-Schema
• Only Schema Types from JAXB exchanged in public interfaces
• Limited customizations
No Canonical Schemas
• Destroys Loose Coupling
• Some fundamental types OK
2008 JavaOneSM Conference | java.com.sun/javaone | 25
Start from Schema
2008 JavaOneSM Conference | java.com.sun/javaone | 26
Schema Validation with JAXB Types
Class[] clazz = {CreditCard.class};
JAXBContext ctx = JAXBContext.newInstance(clazz);
Marshaller m = ctx.createMarshaller();
QName qName = new QName("http://ns.soacookbook.com/credit", "creditCard", "");
JAXBElement<CreditCard> payload = new JAXBElement<CreditCard>(
qName, CreditCard.class, card);
SchemaFactory sf =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(new File(schemaFile)));
m.setSchema(schema);
DocumentBuilder db =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.newDocument();
m.marshal(payload , doc); //return doc, add to SOAPMessage Body
2008 JavaOneSM Conference | java.com.sun/javaone | 27
Schema Design Patterns
Consider Global vs. Local Types
Russian Doll
• Schema mirrors an instance
• Single valid global root element, all other elements local
• Easiest to read and write
• Limits reuse
Salami Slice
• Totally decomposed (no nesting of element declarations)
• Must define all elements to be global--many potential roots
• Confusing
Venetian Blind
• Single valid global root element, all other elements local
• But all of its types are reusable
• Use named complex types, limiting encapsulation
2008 JavaOneSM Conference | java.com.sun/javaone | 28
WSDL Stuff We Did
Started from Java
• Start from WSDL and Java Next Time
Style/Use/Binding=Document/Literal Bare
• Document/Literal Wrapped Next Time
Use Abstract WSDL
• Imports schemas and defines operations
• Protocol Bindings & policies defined externally
Minimal Custom Bindings
• Asynchronous Ops
2008 JavaOneSM Conference | java.com.sun/javaone | 29
External Bindings File async.xml
<bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://java.sun.com/xml/ns/jaxws”
wsdlLocation="SigCapAsync.wsdl">
<bindings node="wsdl:definitions">
<enableAsyncMapping>true</enableAsyncMapping>
</bindings>
2008 JavaOneSM Conference | java.com.sun/javaone | 30
Enabling MTOM - Server Side
@WebService(name="SigCap",
serviceName="SigCapService",
wsdlLocation="META-INF/wsdl/SigCapAsync.wsdl",
targetNamespace="http://ns.dte.com/ws/sigcap")
@Stateless
@Local
@MTOM(enabled=true)
public class SigCapEJB {
@Resource
WebServiceContext wsContext;
public SigCapEJB() { ...
2008 JavaOneSM Conference | java.com.sun/javaone | 31
Using MTOM Client Side
SigCapService service = new SigCapService();
//indicate use MTOM
WebServiceFeature wsf = new MTOMFeature();
//Pass feature to port
SigCap port = service.getSigCapPort(wsf);
Response<AcquireResponse> response =
port.acquireAsync(ip);
while (!response.isDone()) {
System.out.println("Waiting...");
}
id = response.get().getSigCapAcquireResponse();
2008 JavaOneSM Conference | java.com.sun/javaone | 32
BPEL Stuff We Did
Introduce early
Use to totally decouple service invocations
All service-level decision logic available here
• Xpath Content-based routing
• Can invoke rules service
2008 JavaOneSM Conference | java.com.sun/javaone | 33
Discovery (UDDI)
Deferred to never
UBR never happened
• Is anyone really doing this?
We can and want to dictate
Lots about the Business Entity
But we really want a repository...
2008 JavaOneSM Conference | java.com.sun/javaone | 34
SOA Governance
Enforces organizational policies and standards at Strategic
and Technical levels
Strategic:
• Align vision with business. What services? What processes?
How to optimize business processes?
• Education, guidance
Technical:
• How to build, bundle, store, deploy, operate, version, monitor
(runtime KPI)
• BAM, runtime policies
2008 JavaOneSM Conference | java.com.sun/javaone | 35
Agenda
Background
Our Approach to SOA
Tools and API s
Lessons Learned
2008 JavaOneSM Conference | java.com.sun/javaone | 36
BPEL Lessons
Handle faults in smallest possible scope
Look at Compensation Handlers
Allow extension points with <bpel:empty> activity
2008 JavaOneSM Conference | java.com.sun/javaone | 37
Schema Best Practices
Use Namespaces
• URN vs URL for Namespaces: personal preference
• Do not use Chameleon (no namespace) schemas
• Put each SOA element in own NS
• XSD, WS, WSDL, BPEL, ESB
Use “ID” attribute for finer granularity than namespace
<xsd:element id=“urn:dte:product”
name=“product” />
Allow extension points with <xsd:any>
2008 JavaOneSM Conference | java.com.sun/javaone | 38
Organizational Lessons Learned
Create a Central Team
• Standards
• Educate and Evangelize
Introduce through Pilot
• Project of some business value
• Minimize moving parts
• Concurrent Architecture
It’s a Journey
• Think big, start small
• Perform service candidate ontology and cataloging
Governance
• Service Oriented != Project Oriented
• People, Policies, Tools: Integrate & Communicate
2008 JavaOneSM Conference | java.com.sun/javaone | 39
Organizational Lessons Learned Part 2
Have clear, measurable goals for doing SOA
• “Business agility”
• Neither clear nor measurable; unpack it
• “Eliminate nightly batch processing” (OK)
• “Reduce time to market for new applications by 20%” (OK)
Make a roadmap, 3 year plan
Make sure business is on board
• Rarely succeeds as pure tech initiative
Embrace Difference
2008 JavaOneSM Conference | java.com.sun/javaone | 40
Maybe Good Ideas
Read the specs!
Don’t generate what you can’t write
Limit the Pilot Project unknowns
Know schemas, XML, Xpath!
Unit testing imperative!
It’s nice to make a client
2008 JavaOneSM Conference | java.com.sun/javaone | 41
Stuff We’ll Do Next
Governance Repository SOAP over JMS
• Policies
• Processes BPM
• SLA • Derive Candidate Services
• Docs
• BAM
Rules as Service
Security as Service
• SAML and Access Manager
• WS MEx Policies
2008 JavaOneSM Conference | java.com.sun/javaone | 42
NetBeans 6.1, Glassfish v2 u2, Open ESB 2 p4, BPEL
SE
http://www.discounttire.com/JavaOne2008-WS-demo.zip
2008 JavaOneSM Conference | java.com.sun/javaone | 43
Eben Hewitt, DTC
BOF-5433
2008 JavaOneSM Conference | java.com.sun/javaone | 44
Related docs
Other docs by niusheng11
Get documents about "