SlideShare uma empresa Scribd logo
1 de 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)

Mais conteúdo relacionado

Mais procurados

Complete integration with mule esb
Complete integration with mule esbComplete integration with mule esb
Complete integration with mule esbSon Nguyen
 
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-jspsandeep54552
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esbKhasim Cise
 
Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4PawanMM
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptVMahesh5
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in MuleShahid Shaik
 
Log management system for Microservices
Log management system for MicroservicesLog management system for Microservices
Log management system for MicroservicesVõ Duy Tuấn
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3sandeep54552
 
Mule agent architecture
Mule agent architectureMule agent architecture
Mule agent architectureKrishna_in
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
 
Session 25 - Introduction to JEE, Servlets
Session 25 - Introduction to JEE, ServletsSession 25 - Introduction to JEE, Servlets
Session 25 - Introduction to JEE, ServletsPawanMM
 
Mule components
Mule componentsMule components
Mule componentsKrishna_in
 
Java online training
Java online trainingJava online training
Java online trainingVikram Prasad
 
Mule compatible technologies
Mule compatible technologiesMule compatible technologies
Mule compatible technologieshimajareddys
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 

Mais procurados (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
 

Destaque

Destaque (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 .
 

Semelhante a Java Web services

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 StrategyMohamed Taman
 
Java Web services
Java Web servicesJava Web services
Java Web servicesSujit Kumar
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7Lukáš Fryč
 
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 Sagara Gunathunga
 
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)Heartin Jacob
 
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)David Chou
 
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.pptKalsoomTahir2
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
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 RecommendationsJeelani Shaik
 
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 ServicesIMC Institute
 

Semelhante a 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
 

Último

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Último (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

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)