3. Key Features
• Platform independent
• Language independent
• Interoperable across disparate programming
languages
• Leveraging existing technologies (HTTP, XML)
• Supported in SE and EE version of Java
4. Benefits
• Flexibility of supporting unknown future client
platforms
• Use of HTTP
• Easier communication via firewalls and proxies
• Flexible to use a variety of transmission
protocols (ie. SMTP)
5. Disadvantages
• Verbose (can be slower than other
middleware technologies)
• Relying on HTTP, the roles are fixed (only one
party can use the service of the other).
– Service cannot push, client must pull
6. Web Service Standards
• There are two prevailing types:
• Representational State Transfer (REST) – JSR 311
• Simple Object Access Protocol (SOAP) – JSR 224
7. RESTful Web Services
• Representation State Transfer (REST) revolve
around resources (candidate, client, etc)
• The state of the resource is captured and
transferred using the service
8. JAX-RS API
• Does not require any specific data format
• Often CSV, JSON (JavaScript Object Notation), or
XML
• Provides only server-side API
• Can be combined with JAXB or any other Java
XML API
9. Web Service Endpoints
• Remotely executable components that exist
on the server and are executed as a result of
receiving a web service request.
• Both JAX-RS and JAX-WS can use the
following:
• Annotated POJOs
• Session bean components (Stateless or Singleton
beans only)
10. JAVA-RS Endpoints
• The end point is:
• Annotated class created to provide web service
functionality
• Is instantiated per request
• Does not require an EJB container
• JAVA-RS will provide a servlet implementation
to handle the requests
11. JAVA-RS Web Endpoints
• Must have the following:
– @javax.ws.rs.Path class annotation
– Public methods that are annotated with method
designator (ie. @GET)
– Uses @Produces and/or @Consumers annotations
– Cannot be abstract
• Web.xml must have a web a JAVA-RS servlet
configured
– Classes with @Path annotation will be handled by
it.
12. REST Example
1. A resource is given a specific URL (such as
http://localhost/clients/adobe)
2. HTTP methods are used to perform operations
– HTTP GET – retrieves the resource representation
– HTTP POST – adds new element to the resource
– HTTP PUT – creates or updates resource
– HTTP DELETE – deletes the resource
• Content can be of any MIME Type (text, XML, etc.)
13. SOAP Web Services
• Simple Object Access Protocol (SOAP)
• More complex than REST but provides more
benefits
• To implement SOAP client, developer only
needs to know the Web Services Description
Language (WSDL) file, which exposes all API
information
• Utilizes HTTP request/response and XML
14. JAX-WS
• Replaces JAX-RPC
• Required minimal knowledge of XML or WSDL
to use basic services
• Provides both server and client APIssd SOAP
Client Service
JAX-WS runtime JAX-WS runtimeSOAP Message
17. JAVA-WS Endpoints
• Must have the following:
– @javax.jws.WebService annotation
– Public methods (cannot be final or static) with
@javax.jws.WebMethod annotation
– Class cannot be abstract or final
– Must have no args constructor
18. Data Types
• JAX-WS does not contain JAVA to XML binding
• Java Architecture for XML Binding (JAXB) is
designed to handle the binding
• Basic Java types are supported, complex ones
require JAXB programming
19. Java APIs for Web Services
JDOM – provides OO Java model of an XML document
JAXP – abstraction of an XML processing
JAXB – converts objects to XML schemas
JAX-RPC – remote access API (replaced by JAX-WS)
JAXR – standard for using UDDI registries
SAAJ – standard for transmitting and parsing SOAP messages
JAX-RS – RESTful API
JAX-WS – high-level web service API
20. Additional Resources
JSR 224 – Java API for Web Services (JAX-WS)
JSR 331 – Java API for Restful Services (JAX-RS)