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

What's hot (19)

PPT
Complete integration with mule esb
Son Nguyen
 
PDF
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
PPTX
Introduction to mule esb
Khasim Cise
 
PPT
Mule technologies
D.Rajesh Kumar
 
PDF
Mule ESB
Yura Nosenko
 
PPTX
Session 28 - Servlets - Part 4
PawanMM
 
PPTX
Servlet.ppt
VMahesh5
 
PPTX
Soap in mule
D.Rajesh Kumar
 
PPT
Maven introduction in Mule
Shahid Shaik
 
PPTX
Log management system for Microservices
Võ Duy Tuấn
 
PPTX
Enterprise java unit-2_chapter-3
sandeep54552
 
PPTX
Mule agent architecture
Krishna_in
 
PPTX
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 
PPTX
Session 25 - Introduction to JEE, Servlets
PawanMM
 
PPTX
Mule components
Krishna_in
 
PPTX
Java online training
Vikram Prasad
 
PPT
Mule compatible technologies
himajareddys
 
PPTX
Mule soap
Khasim Saheb
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
Complete integration with mule esb
Son Nguyen
 
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
Introduction to mule esb
Khasim Cise
 
Mule technologies
D.Rajesh Kumar
 
Mule ESB
Yura Nosenko
 
Session 28 - Servlets - Part 4
PawanMM
 
Servlet.ppt
VMahesh5
 
Soap in mule
D.Rajesh Kumar
 
Maven introduction in Mule
Shahid Shaik
 
Log management system for Microservices
Võ Duy Tuấn
 
Enterprise java unit-2_chapter-3
sandeep54552
 
Mule agent architecture
Krishna_in
 
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 
Session 25 - Introduction to JEE, Servlets
PawanMM
 
Mule components
Krishna_in
 
Java online training
Vikram Prasad
 
Mule compatible technologies
himajareddys
 
Mule soap
Khasim Saheb
 
JDBC: java DataBase connectivity
Tanmoy Barman
 

Viewers also liked (6)

PPTX
Java 8
vpulec
 
PDF
TYBSc[IT]_SEM-6
Shahbaz Wali Ahmad
 
PPT
Ejb 2.0
sukace
 
PPT
Internet Technology
home
 
PDF
Enterprise Java Beans - EJB
Peter R. Egli
 
PPT
EJB .
ayyagari.vinay
 
Java 8
vpulec
 
TYBSc[IT]_SEM-6
Shahbaz Wali Ahmad
 
Ejb 2.0
sukace
 
Internet Technology
home
 
Enterprise Java Beans - EJB
Peter R. Egli
 
Ad

Similar to Java Web services (20)

PPTX
Jax ws
F K
 
PDF
Java API for XML Web Services (JAX-WS)
Peter R. Egli
 
PDF
Rest web service
Hamid Ghorbani
 
PPTX
Java Web services
Sujit Kumar
 
PDF
Java web services using JAX-WS
IndicThreads
 
PDF
Java Web Services [4/5]: Java API for XML Web Services
IMC Institute
 
PPTX
Soap and restful webservice
Dong Ngoc
 
DOCX
Web services Concepts
pasam suresh
 
PPT
Developing Web Services With Oracle Web Logic Server
Gaurav Sharma
 
PDF
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 
PDF
Restful web services by Sreeni Inturi
Sreeni I
 
PPT
15376199.ppt
abdulbasetalselwi
 
PPTX
Web Services
Nibha Jain
 
PPT
Reusing Existing Java EE Applications from SOA Suite 11g
Guido Schmutz
 
ODP
Web service Introduction
Madhukar Kumar
 
PPTX
Ntg web services
Farag Zakaria
 
PPT
Developing RESTful WebServices using Jersey
b_kathir
 
ODP
SCDJWS 5. JAX-WS
Francesco Ierna
 
PDF
SOAP-based Web Services
Katrien Verbert
 
Jax ws
F K
 
Java API for XML Web Services (JAX-WS)
Peter R. Egli
 
Rest web service
Hamid Ghorbani
 
Java Web services
Sujit Kumar
 
Java web services using JAX-WS
IndicThreads
 
Java Web Services [4/5]: Java API for XML Web Services
IMC Institute
 
Soap and restful webservice
Dong Ngoc
 
Web services Concepts
pasam suresh
 
Developing Web Services With Oracle Web Logic Server
Gaurav Sharma
 
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 
Restful web services by Sreeni Inturi
Sreeni I
 
15376199.ppt
abdulbasetalselwi
 
Web Services
Nibha Jain
 
Reusing Existing Java EE Applications from SOA Suite 11g
Guido Schmutz
 
Web service Introduction
Madhukar Kumar
 
Ntg web services
Farag Zakaria
 
Developing RESTful WebServices using Jersey
b_kathir
 
SCDJWS 5. JAX-WS
Francesco Ierna
 
SOAP-based Web Services
Katrien Verbert
 
Ad

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 

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)