Expose an Stateless Session Bean as a Web Service - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Expose an Stateless Session Bean as a Web Service

Description:

The Basics of Web Services. Benefits of Web Services. Simple Web ... IDEs and other tools. Eclipse Lomboz Jboss (Open source tool set) IBM WebSphere Studio ... – PowerPoint PPT presentation

Number of Views:126
Avg rating:3.0/5.0
Slides: 21
Provided by: Virt
Learn more at: http://people.apache.org
Category:

less

Transcript and Presenter's Notes

Title: Expose an Stateless Session Bean as a Web Service


1
Expose an Stateless Session Bean as a Web Service
  • Jaliya Ekanayake

2
Agenda
  • Few Definitions
  • The Basics of Web Services
  • Benefits of Web Services
  • Simple Web Service Example
  • What is available in J2EE Technology
  • EJB Web Services
  • Exposing an EJB as a Web Service
  • Tools Support
  • Best Practices
  • Sample Scenario

3
Web Services - Basics
  • Definitions
  • Web service is a software application identified
    by a URI RFC 2396, whose interfaces and
    bindings are capable of being defined, described,
    and discovered as XML artifacts. A Web service
    supports direct interactions with other software
    agents using XML based messages exchanged via
    Internet-based protocols. W3C
  • Web services--software components that are
    programmatically accessible over standard
    Internet protocols Java Blue Prints
  • Web Services in 2005
  • But ultimately what I really expect in this
    coming years that that Web services will go from
    that thing that you have tried once or twice, to
    an integral part of almost all your development
    projects. -Matt Powell the content strategist at
    the MSDN Web Services Developer Center.

4
The Model
Client
Server
SOAP Handler
SOAP Handler
Client
Service
SOAP msg
SOAP msg
Network
The Web Services Model
  • SOAP Handler
  • Takes the parameters from the native client
    address space and transform (serialize) then to
    SOAP.
  • Takes the SOAP from the network and transform
    (de-serialize) it to parameters of the native
    service address space.
  • SOAP Handler may accept SOAP messages sent on
    various transport protocols.
  • E.g. HTTP, SMTP, TCP etc..
  • HTTP is the most popular protocol

5
Benefits of Web Services
  • Interoperability in a heterogeneous environment
  • Business services through the Web
  • Integration with existing systems
  • Tools Support
  • Support more client types
  • Programming productivity

6
Simple Web Service Example
  • Simplest way is to use JSE(JAX-RPC Service
    Endpoint)
  • Expose Java classes directly as web services
  • Can use SOAP Endpoints based on Servlet
    Containers, e.g. Apache Axis
  • E.g. JSE with SOAP over HTTP
  • Example Using Apache Axis
  • The Code Snippet for the Service gtgt
  • The Code Snippet for the client gtgt
  • Demo

SOAP Handler
Service
SOAP Over HTTP
Servlet Container
JAX-RPC Service Endpoint with SOAP Over HTTP
7
What is available in J2EE Technology
  • EJB components, by design, are meant for
    distributed computing
  • EJB components are scalable, transactional, and
    secure
  • J2EE Containers provide primary services such as
    Naming, Login, Transaction, Deployment and
    Security
  • Developer can focus more on Business Logics
  • Tons of applications have already bean written
    using EJBs

8
EJB Web Services (JSR 109)
  • J2EE 1.4 Allows JAX-RPC (JSR 101) Web Services
    using Stateless Session Beans.
  • JAX-RPC hides the complexity of SOAP messages
    from the developer.
  • J2EE web services can be invoked by any web
    service client, and any J2EE web service client
    can invoke any web service.

9
Exposing an Stateless EJB as a Web Service
  • Simple Steps
  • Define the service interface (Depending on the
    business functionality that needs to be exposed)
    gtgt
  • Generate the WSDL for the above service end point
    gtgt
  • E.g. Using Java2WSDL from Apache
  • java org.apache.axis.wsdl.Java2WSDL -a -o
    "CardValidatorService.wsdl" -n "urnejb-ws" -l
    "REPLACE_WITH_ACTUAL_URL" test.ejb.CardValidatorSe
    rvice
  • Create or Generate JAX-RPC Mapping file gtgt
  • Add the WSDL JAX-RPC Mapping file to the Manifest
  • Modify the ejb-jar.xml gtgt
  • Add webservices.xml gtgt
  • Package and Deploy
  • Demo
  • Accessing the web service can be done by J2EE,
    J2SE, J2ME or any other clients that are running
    on different platforms.

10
Tools Support
  • Servers that support JSR109
  • Sun Java System Application Server Platform
    Edition 8.1
  • JBOSS-4.0.1RC1
  • Oracle Application Server Containers for J2EE
    (OC4J) 10.0.3
  • Sun ONE (Open Network Environment) Application
    Server
  • IBM Websphere V6
  • Weblogic Server 7.0
  • Apache Geronimo
  • IDEs and other tools
  • Eclipse Lomboz Jboss (Open source tool set)
  • IBM WebSphere Studio
  • Sun Java System Application Server Platform
    Edition 8.1

11
Best Practices
  • Services should be coarse grain
  • Avoid overusing Web services in your applications
  • Design your Web service so that it creates
    minimal network traffic gtgt
  • Avoid maintaining any kind of state information
    in your EJB components that are exposed as Web
    services.
  • Use JAX-RPC data types as the method parameters
    for the Web service to give it interoperability
    with heterogeneous Web services
  • Avoid types such as Collection, HashMap, and
    Lists as parameters for your Web service if
    interoperability is important for your
    application
  • Avoid exposing an EJB component that involves
    long-running transactions as a Web service.
  • Weigh the security requirements against
    performance, because security comes with a higher
    cost. The performance costs of end-to-end
    security are high.

12
Known Limitations and Issues
  • Some Web Service Standards are still in draft
    level
  • May degrade the performance if used incorrectly
  • Possible security threats (SOAP over HTTP)
  • Interoperability issues (WS-I Basic Profile)
  • Matching Requirements

13
Sample Scenario
14
Summary
  • Basics of Web Services
  • What is already there in J2EE
  • How to expose an EJB as a Web Service
  • Best Practices

15
References
  • JBOSS Documentation
  • http//docs.jboss.org/jbossas/getting_started/star
    tguide40/ws.html
  • Designing Web Services with the J2EE 1.4
    Platform JAX-RPC, SOAP, and XML Technologies
  • http//java.sun.com/blueprints/guidelines/designin
    g_webservices/
  • Web Services for J2EE, Version 1.0 (JSR109)
  • ftp//www-126.ibm.com/pub/jsr109/spec/1.0/websvcs-
    1_0-fr.pdf
  • Tutorial for building J2EE Applications using
    JBOSS and ECLIPSE
  • http//www.tusc.com.au/tutorial/html/chap1.html
  • http//www.javaworld.com/javaworld/jw-08-2004/jw-0
    802-ejbws.html
  • http//publib.boulder.ibm.com/infocenter/iadthelp/
    index.jsp?topic/com.ibm.etools.webservice.doc/con
    cepts/cjsr109.html
  • http//dev2dev.bea.com/products/wlserver/articles/
    Gilbode.jsp
  • http//incubator.apache.org/projects/geronimo/
  • http//java.sun.com/developer/technicalArticles/J2
    EE/j2ee_ws/design

16
Thank You
17
CardValidator Web Service (JSE)
  • ltlt

18
CardValidator Client (JSE)
  • ltlt

19
Web service endpoint for the stateless EJB
  • ltlt

20
ejb-jar.xml
  • ltlt
Write a Comment
User Comments (0)
About PowerShow.com