SlideShare ist ein Scribd-Unternehmen logo
1 von 20
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)

Weitere ähnliche Inhalte

Was ist angesagt?

Java online training
Java online trainingJava online training
Java online training
Vikram Prasad
 

Was ist angesagt? (19)

Complete integration with mule esb
Complete integration with mule esbComplete integration with mule esb
Complete integration with mule esb
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Mule technologies
Mule technologiesMule technologies
Mule technologies
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Soap in mule
Soap in muleSoap in mule
Soap in mule
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Log management system for Microservices
Log management system for MicroservicesLog management system for Microservices
Log management system for Microservices
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
 
Mule agent architecture
Mule agent architectureMule agent architecture
Mule agent architecture
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Session 25 - Introduction to JEE, Servlets
Session 25 - Introduction to JEE, ServletsSession 25 - Introduction to JEE, Servlets
Session 25 - Introduction to JEE, Servlets
 
Mule components
Mule componentsMule components
Mule components
 
Java online training
Java online trainingJava online training
Java online training
 
Mule compatible technologies
Mule compatible technologiesMule compatible technologies
Mule compatible technologies
 
Mule soap
Mule soapMule soap
Mule soap
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 

Andere mochten auch (6)

Java 8
Java 8Java 8
Java 8
 
TYBSc[IT]_SEM-6
TYBSc[IT]_SEM-6TYBSc[IT]_SEM-6
TYBSc[IT]_SEM-6
 
Ejb 2.0
Ejb 2.0Ejb 2.0
Ejb 2.0
 
Internet Technology
Internet TechnologyInternet Technology
Internet Technology
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
EJB .
EJB .EJB .
EJB .
 

Ähnlich wie Java Web services

Java Web services
Java Web servicesJava Web services
Java Web services
Sujit Kumar
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
Lukáš Fryč
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
KalsoomTahir2
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1
Д. Ганаа
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik
 

Ähnlich wie Java Web services (20)

What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Java Web services
Java Web servicesJava Web services
Java Web services
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Coursejspservlets00
Coursejspservlets00Coursejspservlets00
Coursejspservlets00
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup
 
Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)
 
Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)
 
Java part 3
Java part  3Java part  3
Java part 3
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
 
Oracle API Gateway
Oracle API GatewayOracle API Gateway
Oracle API Gateway
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Advance java1.1
Advance java1.1Advance java1.1
Advance java1.1
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Java Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesJava Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web Services
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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)