Why J2EE for Web Services
Document Sample


12/11/2002
Survive the test of time We make the net work Survive the test of time
Sang Shin
sang.shin@sun.com
Java ™ Technology Evangelist
J2EE & TM
Sun Microsystems, Inc.
Web Services www.plurb.com/webservices/
2
Survive the test of time Survive the test of time
Agenda
• Why J2EE as Web services platform?
• Web services architecture over J2EE
• Web services development steps over J2EE
• Java APIs for Web services
• Web services tools over J2EE Why J2EE
•
•
J2EE 1.4 Status
Future of Web Services
for Web Services?
3 4
12/11/2002
Survive the test of time Survive the test of time
Why J2EE for Web Services? Where Are We Now?
• Web services is just one of many • Java APIs for Web Services are being
service delivery channels of J2EE developed very rapidly
• Web services support on WUST (WSDL, UDDI,
– No architectural change is required
SOAP) ready now
– Existing J2EE components can be easily • Next layer Web services work in progress
exposed as Web services
• Tools are available now for exposing
• Many benefits of J2EE are preserved existing J2EE components as Web services
for Web services • J2EE community is in the process of
– Portability, Scalability, Reliability defining overall framework for Web
– No single-vendor lock-in Services (J2EE 1.4, Web services for J2EE)
5 6
Survive the test of time Survive the test of time
Design Goals J2EE Web Services J2EE Web Services Framework
Framework
• J2EE 1.4 is an umbrella framework
• Portability of Web services component for Web services
– Over different vendor platform
– Web services for J2EE (JSR 109)
– Over different operational environment
– JAX-RPC
• Leveraging existing J2EE programming
models for service implementation – SAAJ
– JAXR
• Easy to program and deploy
– EJB 2.1
– High-level Java APIs
– Use existing deployment model – Connector architecture 1.5
7 8
12/11/2002
Survive the test of time Survive the test of time
Web Services for J2EE (JSR 109) JAX-RPC
• Addresses overall Web services • XML data types to/from Java types mapping
architecture over J2EE • WSDL to/from Java mapping
– Client model
• JAX-RPC Client Programming Models:
– Service provider model
– Stub, Dynamic proxy, Dynamic invocation
– Deployment model
– WSDL binding
• Servlet-based service endpoint model
– Security • SOAP Message Handler framework
• Incorporates JAX-RPC, EJB 2.1 • Extensible type mapping
9 10
Survive the test of time Survive the test of time
SAAJ (SOAP with Attachment API
Web Services Support in EJB 2.1
for Java)
• Defines Stateless Session Bean-based Web
• Contains the API for creating and populating
services endpoint model
a SOAP messages conforming to SOAP 1.1
and SOAP with Attachment specifications • Stateless session bean can be a form of web
services implementation
• Contains API necessary for sending request- • Web services endpoint interface (service definition
response (non-provider-model) messages interface) for Stateless session bean
• Can implement SOAP Message Handlers for
• Separated out from JAXM 1.0 into JAXM 1.1 Stateless session bean based endpoint
and SAAJ 1.1
• Defines programming models for invoking
Web services from EJB beans
11 12
12/11/2002
Survive the test of time Survive the test of time
JAXR Where is JAXM?
• Standard Java API for performing • JAXM is not part of J2EE 1.4
registry operations over diverse set • JAXM-based asynchronous messaging
of registries on J2EE 1.4 is supported via
– Service publication & discovery • Message-driven Bean (MDB) in EJB 2.1 can
• A unified information model for receive both JMS and JAXM message types
describing business registry content • Connector 1.5 allows pluggability of various
types message providers (JAXM provider and
• Provides multi-layered API JMS provider)
abstractions
– Level 0 for UDDI, Level 1 for ebXML reg/rep 13 14
Survive the test of time Survive the test of time
What Is a Web Service?
• A set of endpoints operating on messages
• Endpoints are operating within a container
• Container provides runtime environment
• Contract for runtime environment are specified in
Web Services JAX-RPC, EJB 2.1, JSR 109
Service is described abstractly in WSDL
Architecture •
document and published to a registry
Over J2EE •
• Contract between service provider and user
Service are bound to XML-based protocol
15
(SOAP) and transport (HTTP, SMTP)
16
12/11/2002
Survive the test of time Survive the test of time
Client View of Web Service Service Provider View
• Discover WSDL description of service
• Create WSDL describing a web service
• Identify service provider endpoint address
• Create artifacts (i.e. stub) to use service, based • Implement service endpoint
on port-type descriptions in WSDL (via tool) • Publish service (WSDL)
• Send messages to endpoints that provide service
implementation • Deploy service
• Receive back messages that contain results • Service instance selection
• Sending and receiving messages can look
like RPC to client
• JAX-RPC API simplifies “Java client view”
17 18
Survive the test of time Survive the test of time
Web Services for the J2EE 1.4 Platform Web Service Component and
• Client View Container
– JAX-RPC • Container vs. Component model
– Web service is 1st-class J2EE component
• Server View
– Servlet based endpoint • Web service component
• JAX-RPC – Uses J2EE programming model for
• Runtime is provided by Web container implementation of business logic
– Stateless Session Bean based endpoint – Deployment descriptor
• EJB 2.1 • Web service container
• Runtime is provided by EJB container
19 – Runtime binding to transports, port 20
12/11/2002
Survive the test of time Survive the test of time
Example: Web service Client View
Public class InvestmentBean
implements SessionBean{
public void checkPortfolio(...) {
Context ctx = new InitialContext();
StockQuoteService sqs = ctx.lookup(
"java:comp/env/service/StockQuoteService");
Web Service
StockQuoteProvider sqp =
sqs.getStockQuoteProviderPort();
float quotePrice = sqp.getLastTradePrice(...);
Development Steps
...
}
}
Over J2EE
21 22
Survive the test of time Survive the test of time
Steps for Development and I. Defining a Web Service
Deployment of Web Services: • Web service is defined in
I. Define a Web service – WSDL or
II. Implement the Web service – Web service endpoint interface (Java interface)
III. Produce deployment ready package • Top-down approach
IV. Deploy package over J2EE platform – WSDL is created (or found) first before
its implementation
V. Publish the Web service and binding
information to a service registry • Bottom-up approach
VI. Serve service requests from client – WSDL gets generated from existing
23 J2EE components
24
12/11/2002
Survive the test of time Survive the test of time
Web Service Endpoint Interface Example:
• A Java interface type as specified in JAX-RPC Web Service Endpoint Interface
• Must extend java.rmi.Remote
public interface StockQuoteProvider
• Needed for both servlet-based and extends java.rmi.Remote {
stateless session bean based endpoint public float getLastTradePrice(String tickerSymbol)
throws java.rmi.RemoteException;
• Could be generated from WSDL }
...
• For Stateless session bean based endpoint
• Declare in deployment descriptor for session
bean using service-endpoint element
25 26
Survive the test of time Survive the test of time
II. Implement Web Service Web Services Endpoint
1. Choose implementation form
Architecture
– Java class (for servlet-based endpoint)
– Stateless session bean
2. Implement business logic for methods
– Deployment tools generate needed artifacts for
runtime
– Container dispatches invocations on service
endpoint to either Java class or session bean
instance
3. Create deployment descriptor
27 28
12/11/2002
Survive the test of time Survive the test of time
Example Implementation: Example Implementation:
Java Class for Servlet-based Endpoint Stateless Session Bean Class
public class StockQuoteProviderImpl public class StockQuoteProviderBean
implements StockQuoteProvider {
implements javax.ejb.SessionBean {
public float getLastTradePrice(String tickerSymbol)
throws java.rmi.RemoteException{
public float getLastTradePrice(String tickerSymbol)
// business logic for method
} throws java.rmi.RemoteException{
} // business logic for method
}
...
}
29 30
Survive the test of time Survive the test of time
III. Create Deploy'able package Web Services Deployment Descriptor
• Ready-to-deploy'able package • webservices.xml
– Portable – DTD is defined in JSR 109
• Standardization for portability via JSR 109
• Roles
– Package structure
– Developer
– Web Services Deployment descriptor
– Assembler
• Package might contain
– WSDL documents
– Deployer
– Web Services Deployment descriptor
– Contents or references to J2EE components
31 32
12/11/2002
Survive the test of time Survive the test of time
IV. Deploy Package
• Responsibility of Container
– Create runtime artifacts
– Select transport and port
Java APIs
for Web Services
33 34
Survive the test of time Survive the test of time
Java APIs for SOAP, WSDL, UDDI Java APIs for ebXML
• SOAP Messaging • ebXML Message Service (TR&P)
– JAXM (JSR 67), SAAJ, JAX-RPC (JSR 101), JMS – JAXM (JSR 67) with ebXML Message Service profile
• WSDL • ebXML Registry/Repository
– Java API for WSDL (JSR 110) – JAXR (JSR 93)
– JAX-RPC (JSR 101) • CPP/CPA
– Java API for ebXML CPP/CPA (JSR 157)
• UDDI
– JAXR (JSR 67)
35 36
12/11/2002
Survive the test of time Survive the test of time
J2EE Web Services Framework Java APIs for XML
• J2EE 1.4 (JSR 151) Document Management
• Web services for J2EE (JSR 109) • JAXP (Java API for XML processing, JSR 05)
• Assembly language for XML document processing
• JAX-RPC (JSR 101) • JAXB (Java API for XML data-binding, JSR 31)
• JAXR • Higher level language for XML document processing
• SAAJ • Streaming API for XML (JSR 173)
• EJB 2.1 • Pull-parsing API based on Iterator
37 38
Survive the test of time Survive the test of time
Java APIs for XML Security More Java APIs for Web Services
• XML Digital Signature (JSR 105) • XML Transactioning API for Java (JSR 156)
• XML Encryption (JSR 106) • Java API for OASIS BTP
• XML Trust Service (JSR 104) • Java Process Component API (JSR 159)
• Loosely coupled, event-driven
• Secure Assertion Markup Language
(SAML, JSR 155) • Web Services for J2ME (JSR 172)
• SOAP messaging for J2ME devices
• WS-Security (JSR 183)
• Web Services Metadata for J2EE (JSR 181)
• Metadata based Web services
39 40
12/11/2002
Survive the test of time Survive the test of time
Java Web Services Developer Pack
(Java WSDP)
• Provides a convenient all-in-one package
– Can be run over J2EE RI
• Contains
– JAXP, JAXM, SAAJ, JAX-RPC, JAXR
Web Services –
–
Tomcat
JSP Tag Library (JSTL)
Tools for J2EE
– JSSE (Java Secure Socket Extension)
– Ant build tool
– Web application deployment tool
– Java WSDP Registry Server (UDDI server)
• FCS'ed June, 2002, Production quality, Free
41 42
Survive the test of time Survive the test of time
Sun ONE Studio 4 EE
(with built-in SOAP-RPC module)
• Expose business functions of of stateless session
bean as Web services
• Create WSDL document from business functions
• Create server side artifacts for the deployment
• Create client stub from WSDL document
•
•
Create HTML based test code
Register WSDL document to UDDI registry J2EE 1.4 Status
• Discover WSDL document from UDDI registry
• Runs over either J2EE RI or Sun ONE app server
43 44
12/11/2002
Survive the test of time Survive the test of time
J2EE 1.4 Status
• Proposed Final Draft published on Aug. 21,
2002
• J2EE Reference Implementation Beta is
available right now! (as of Nov. 2002)
• Final release is scheduled during early 20o3 Future of
Web Services
45 46
Survive the test of time Survive the test of time
Web Services Adoption Phases Web Services Adoption Phases
st
• 1 phase (current state)
– Concerted deployment internally within an
• 1st Phase – Simple Web Services (Now)
organization mainly for interoperability – Consumer-focused, stateless
nd
– SOAP over HTTP • 2 Phase – EAI Web Services (Begun)
nd
• 2 phase (1 to 2 years) – Deployed within organization boundaries to
– Selective and non-aggregate deployment with enable internal integration
trusted outside business partners
• 3rd Phase – Business Web Services (2004?)
– Private registry deployment
– Deployed on Extranets to enable business process
• 3r d phase (at least 3 to 4 years away) integration with trading partners, customers,
– Wider, more dynamic and aggregate deployment other players in your value chain
with outside business partners
– Public registry deployment 47 48
12/11/2002
Survive the test of time Survive the test of time
Business Web Services (B2B)
Architectural Components (ebXML)
• B2B collaboration
• Secure and reliable message delivery
• Non-repudiation
• Partner profile Identity Management
• Repository for business data objects & Liberty
49 50
Identity Crisis—Silos of Identity
Possible Identity Solutions
Centralized Open Federated
Model Model Financial Svcs
Customer
Community
Single Identity
Operator Online Wireless
Community Community
Retail
Telecommunications Community
Community
Travel
Entertainment Community
Community
51 Session 1120
52 Session 1120
12/11/2002
Survive the test of time Survive the test of time
Resources on J2EE Specifications
• J2EE Home Page
– java.sun.com/j2ee
• J2EE 1.4 (JSR 151)
– www.jcp.org/jsr/detail/151.jsp
• Web Services for J2EE (JSR 109)
Resources •
– www.jcp.org/jsr/detail/109.jsp
JAXM, JAX-RPC, JAXR
– java.sun.com/xml
53 54
Survive the test of time Survive the test of time
Resources on Web Services Tools Call for Action
• Java Web Services Developer Pack Download
– java.sun.com/webservices/downloads/webservicespack.html
• Download and run Java Web Services
• Java Web Services Developer Pack Tutorial
Developer Pack and Tutorial now!
– java.sun.com/webservices/downloads/webservicestutorial.html • Download Sun ONE Studio 4 EE and Web
• Sun ONE Studio 4 EE services tutorials now!
– wwws.sun.com/software/sundev/jde/buy/index.html
• Sun ONE Studio Web services tutorial
– wwws.sun.com/software/sundev/jde/examples/index.html
? Sang Shin's Web Services Class Website
– www.plurb.com/webservices/index.html
55 56
12/11/2002
Survive the test of time
Q&A
57
Related docs
Get documents about "