SlideShare a Scribd company logo
Java EE 6 – Web Service
Vladan Pulec
Objectives
 Overview
 Distinguish between the two types of web
services
 RESTful Service & Demo
 Web Service & Demo
Key Features
• Platform independent
• Language independent
• Interoperable across disparate programming
languages
• Leveraging existing technologies (HTTP, XML)
• Supported in SE and EE version of Java
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)
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
Web Service Standards
• There are two prevailing types:
• Representational State Transfer (REST) – JSR 311
• Simple Object Access Protocol (SOAP) – JSR 224
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
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
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)
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
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.
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.)
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
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
Sample SOAP Request
• <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/“
xmlns:xsd="http://www.w3.org/2001/XMLSchema“ xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
• <SOAP-ENV:Header>
• <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd">
• <wsse:UsernameToken>
• <wsse:Username>123456</wsse:Username>
• <wsse:Password>mypassword</wsse:Password>
• </wsse:UsernameToken>
• <service_attributes ignore_warnings="false" />
• </wsse:Security>
• </SOAP-ENV:Header>
• <SOAP-ENV:Body>
• <ser:findByTestCenterID xmlns:ser="http://services.capacity.vue/">
• <testCenterID>4</testCenterID>
• </ser:findByTestCenterID>
• </SOAP-ENV:Body>
• </SOAP-ENV:Envelope>
sd SOAP
Envelope
Header
Body
Sample SOAP Response
• <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
• <soap:Body>
• <ns2:findByTestCenterIDResponse xmlns:ns2="http://services.capacity.vue/">
• <workstationSearchResponse>
• <testCenter id="4" name="Electronic Systems" tws="-1" />
• <workstationRules>
• <workstationRule activeRuleCount="1">
• <asset assetCategoryCode="Workstation" assetID="53412"
• assetName="Test 7" siteID="4" isEnabled="true" />
• </workstationRule>
• </workstationRules>
• </workstationSearchResponse>
• </ns2:findByTestCenterIDResponse>
• </soap:Body>
• </soap:Envelope>
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
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
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
Additional Resources
JSR 224 – Java API for Web Services (JAX-WS)
JSR 331 – Java API for Restful Services (JAX-RS)

More Related Content

PPTX
JEE session 1
PDF
Jeetrainers.com coursejspservlets00
PPTX
Mule esb overview
PDF
Jive the renovation of Aswing
PDF
Ch. 13 filters and wrappers
PPTX
PDF
Global Scale ESB with Mule
PPT
Weblogic Server Overview Weblogic Scripting Tool
JEE session 1
Jeetrainers.com coursejspservlets00
Mule esb overview
Jive the renovation of Aswing
Ch. 13 filters and wrappers
Global Scale ESB with Mule
Weblogic Server Overview Weblogic Scripting Tool

What's hot (19)

PPT
Complete integration with mule esb
PDF
Enterprise java unit-3_chapter-1-jsp
PPTX
Introduction to mule esb
PPT
Mule technologies
PDF
Mule ESB
PPTX
Session 28 - Servlets - Part 4
PPTX
Servlet.ppt
PPTX
Soap in mule
PPT
Maven introduction in Mule
PPTX
Log management system for Microservices
PPTX
Enterprise java unit-2_chapter-3
PPTX
Mule agent architecture
PPTX
Java/Servlet/JSP/JDBC
PPTX
Session 25 - Introduction to JEE, Servlets
PPTX
Mule components
PPTX
Java online training
PPT
Mule compatible technologies
PPTX
Mule soap
PPSX
JDBC: java DataBase connectivity
Complete integration with mule esb
Enterprise java unit-3_chapter-1-jsp
Introduction to mule esb
Mule technologies
Mule ESB
Session 28 - Servlets - Part 4
Servlet.ppt
Soap in mule
Maven introduction in Mule
Log management system for Microservices
Enterprise java unit-2_chapter-3
Mule agent architecture
Java/Servlet/JSP/JDBC
Session 25 - Introduction to JEE, Servlets
Mule components
Java online training
Mule compatible technologies
Mule soap
JDBC: java DataBase connectivity
Ad

Viewers also liked (6)

PPTX
Java 8
PDF
TYBSc[IT]_SEM-6
PPT
Ejb 2.0
PPT
Internet Technology
PDF
Enterprise Java Beans - EJB
PPT
Java 8
TYBSc[IT]_SEM-6
Ejb 2.0
Internet Technology
Enterprise Java Beans - EJB
Ad

Similar to Java Web services (20)

PPTX
Jax ws
 
PDF
Java API for XML Web Services (JAX-WS)
PDF
Rest web service
PPTX
Java Web services
PDF
Java web services using JAX-WS
PDF
Java Web Services [4/5]: Java API for XML Web Services
PPTX
Soap and restful webservice
DOCX
Web services Concepts
PPT
Developing Web Services With Oracle Web Logic Server
PDF
Lecture 7 Web Services JAX-WS & JAX-RS
PDF
Restful web services by Sreeni Inturi
PPT
15376199.ppt
PPTX
Web Services
PPT
Reusing Existing Java EE Applications from SOA Suite 11g
ODP
Web service Introduction
PPTX
Ntg web services
PPT
Developing RESTful WebServices using Jersey
ODP
SCDJWS 5. JAX-WS
PDF
SOAP-based Web Services
Jax ws
 
Java API for XML Web Services (JAX-WS)
Rest web service
Java Web services
Java web services using JAX-WS
Java Web Services [4/5]: Java API for XML Web Services
Soap and restful webservice
Web services Concepts
Developing Web Services With Oracle Web Logic Server
Lecture 7 Web Services JAX-WS & JAX-RS
Restful web services by Sreeni Inturi
15376199.ppt
Web Services
Reusing Existing Java EE Applications from SOA Suite 11g
Web service Introduction
Ntg web services
Developing RESTful WebServices using Jersey
SCDJWS 5. JAX-WS
SOAP-based Web Services

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
A Presentation on Artificial Intelligence
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Electronic commerce courselecture one. Pdf
PPTX
Big Data Technologies - Introduction.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Group 1 Presentation -Planning and Decision Making .pptx
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
Tartificialntelligence_presentation.pptx
MIND Revenue Release Quarter 2 2025 Press Release
A Presentation on Artificial Intelligence
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Electronic commerce courselecture one. Pdf
Big Data Technologies - Introduction.pptx

Java Web services

  • 1. Java EE 6 – Web Service Vladan Pulec
  • 2. Objectives  Overview  Distinguish between the two types of web services  RESTful Service & Demo  Web Service & Demo
  • 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
  • 15. Sample SOAP Request • <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/“ xmlns:xsd="http://www.w3.org/2001/XMLSchema“ xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance"> • <SOAP-ENV:Header> • <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext- 1.0.xsd"> • <wsse:UsernameToken> • <wsse:Username>123456</wsse:Username> • <wsse:Password>mypassword</wsse:Password> • </wsse:UsernameToken> • <service_attributes ignore_warnings="false" /> • </wsse:Security> • </SOAP-ENV:Header> • <SOAP-ENV:Body> • <ser:findByTestCenterID xmlns:ser="http://services.capacity.vue/"> • <testCenterID>4</testCenterID> • </ser:findByTestCenterID> • </SOAP-ENV:Body> • </SOAP-ENV:Envelope> sd SOAP Envelope Header Body
  • 16. Sample SOAP Response • <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> • <soap:Body> • <ns2:findByTestCenterIDResponse xmlns:ns2="http://services.capacity.vue/"> • <workstationSearchResponse> • <testCenter id="4" name="Electronic Systems" tws="-1" /> • <workstationRules> • <workstationRule activeRuleCount="1"> • <asset assetCategoryCode="Workstation" assetID="53412" • assetName="Test 7" siteID="4" isEnabled="true" /> • </workstationRule> • </workstationRules> • </workstationSearchResponse> • </ns2:findByTestCenterIDResponse> • </soap:Body> • </soap:Envelope>
  • 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)