SlideShare a Scribd company logo
Overview of Java Web Services
Sujit Kumar
Zenolocity LLC © 2013-2023
What are web services
• Reusable web application components that
provide software functions at a network
address over the web with the service always
on.
• Interoperable between heterogeneous
systems (language & platform independent)
across the network.
• Interface described by WSDL.
2 Types
• REST compliant web services.
• SOAP based web services.
WSDL
• Contract between caller and callee that
describes a web service using XML format.
• Set of operations available at a network
address using a specific protocol and data
format.
• Each operation has an input request message
and an output response message.
Analogies for a WSDL
• WSDL – interface in java.
• Operations – static methods in a java object.
• Input Message of an operation – argument
passed to a java method.
• Output Message of an operation – argument
returned from a java method.
• Types – Classes in Java, without any methods.
WSDL Elements
• Types – data type definitions
• Messages – definition of data being
exchanged.
• Port Type – set of operations exposed at a
network address.
• Binding – protocol (SOAP over http) and data
format specification.
SOAP
• XML based communication protocol for
accessing Web Services.
• Language and Platform Independent.
• SOAP provides a way for applications to
communicate with each other over HTTP. The
applications could be running on different
operating systems with different technologies
and programming languages.
SOAP XML Message Elements
• Envelope – wraps everything
• Header (optional)
• Body – appears after Header.
• Fault (optional) – part of the body
Example SOAP Message
• <?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-
encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
JAXB
• Java Architecture for XML Binding (JAXB)
• Two main features:
Marshall live java objects into XML data.
Un-marshall XML data into live java objects.
• Part of the Java SE platform.
• One of the APIs in the Java EE platform.
• Also, part of the Java Web Services
Development Pack (JWSDP).
XML, XSD & Tools for JAXB
• Analogy: XML is like an object, XSD is like a
class or a type. XML should be well formed
(syntactically correct) and valid (conform to an
XSD).
• xjc – convert xsd schemas to java classes.
Address.xsd  xjc  Address.java
• schemagen – convert annotated java classes
to schema definitions.
Address.java  schemagen  Address.xsd
JAX-WS
• Java API for creating web services.
• Part of Java EE platform.
• Defines a standard for Java-to-WSDL mapping.
• Determines how WSDL operations are bound
to Java methods.
• Determines how SOAP messages are mapped
to java method arguments and return values.
• Can be used in Java SE from version 6.0.
JAX-WS Tools
• wsimport : top-down approach. Reads WSDL
file & generates portable artifacts that
includes SEI (service endpoint
implementation), jaxb classes from schema
types and exceptions from faults.
• wsgen : bottom-up approach. Reads an SEI
class and generates the portable artifacts for
web service development and deployment.
• Both are part of JDK 6 and above.
JAX-WS Implementations
• Metro Project in Glassfish (open source)
• Apache CXF
• Apache Axis 2
• Oracle WebLogic
• IBM WebSphere
• JBossWS
• Each of the above provides a wsdltojava utility
and provide implementations for the interfaces in
the JAX-WS api.
Converting WSDL to Java
• Vendor provided wsldtojava utilitiy or wsimport
utility in JDK 6.
• Can be configured to run as an eclipse plugin, or
invoked via command line utility or as an
ANT/Maven task.
• Output of Wsdl2Java is client stubs and skeletons.
• Stubs are used to invoke the remote web
services, actual business logic is written in the
skeletons.
Comparison of JAX-WS
Implementations
• http://wiki.apache.org/ws/StackComparison
• http://predic8.com/axis2-cxf-jax-ws-
comparison.htm
• http://www.ibm.com/developerworks/java/lib
rary/j-jws19/index.html
Service Oriented Architecture (SOA)
• Software architecture design pattern.
• Based on discrete pieces of software providing application
functionality as services to other applications.
• Characteristics of a service:
• Service Contract (defined via service description
documents)
• Loose Coupling (minimize dependencies)
• Reusable
• Abstraction (hide implementation logic)
• Location transparency, discoverable, stateless &
composable.
SOA and Web Services
• Web Services are an implementation of SOA.
• SOAP & REST are implementations of Web
Services.
• Web Service contract exposed via WSDL.
Web Services Implementation
Mechanisms
• Contract First or top-down : create the WSDL
first and then generate the stubs and
skeletons. WS Consumers use the stubs to
invoke the service implemented by the WS
Provider in the skeletons.
• Contract Last or bottom-up. Implement the
business logic first in the WS Provider. Extract
WSDL after the implementation.
• Contract first is usually preferred.
Benefits of Contract First
• Looser Coupling between contract and
implementation. Implementation logic can be changed
without affecting clients.
• Easier to keep contracts constant for longer periods of
time. Contracts can be fragile and change constantly. In
order for a contract to be useful, it must remain
constant for as long as possible.
• If a contract changes, you will have to contact all of the
users of your service, and instruct them to get the new
version of the contract.
• Enables parallel development of clients and service.
RESTful Services
• Architectural Style based on HTTP.
• Client-Server : separation of responsibilities promotes
portable clients & scalable servers.
• Stateless – no client context saved on server.
• Cacheable – clients can cache responses, improves
performance & scalability.
• Uniform Interface: identification of resources using
URIs. The resources themselves are conceptually
separate from the representations that are returned to
the client. For example, the server does not send its
database, but will send XML or JSON that represents
some database records.
RESTful Services
• Uniform Interface: Manipulation of resources
through these representations held by the
client.
• Uniform Interface: Self-descriptive messages.
Each message has enough information to
describe how to process the message.
• If a service violates any of the required
constraints, it cannot be considered RESTful.
RESTful Services
• Manipulate resources (CRUD) using HTTP
methods.
• GET – Retrieve
• PUT – Create or Update
• DELETE – Remove
• POST - Create
• GET, PUT and DELETE are idempotent, POST is not
idempotent.
• Idempotent implies:
y = f(x), y = f(f(x)), y = f(f(f(x)))
Difference between PUT and POST
• POST – create a child of the resource
identified by the URI.
• PUT – create or update the resource identified
by the URI.
Considerations to use PUT vs POST
• Do you name your URL objects you create
explicitly, or let the server decide? If you name
them then use PUT. If you let the server
decide then use POST.
• PUT is idempotent, so if you PUT an object
twice, it has no effect, then use PUT when
possible.
• You can update or create a resource with PUT
with the same object URI.
RESTful Methods applied to single
resource or collection of resources
STful API HTTP methods
Resource GET PUT POST DELETE
Collection URI
tp://example.com
/resources
List the URIs and
perhaps other
details of the
collection's
members.
Replace the entire
collection with
another collection.
Create a new entry
in the collection.
The new entry's URI
is assigned
automatically and is
usually returned by
the operation.
Delete the en
collection.
Element URI
tp://example.com
resources/item17
Retrieve the specific
member of the
collection.
Replace the
addressed member
of the collection, or
if it doesn't exist,
create it.
Not generally used.
Treat the specific
member as a
collection &
create a new entry
in it.
Delete the sp
member of th
collection.
Implementations of RESTful web
services
• Use JSR 311(JAX-RS) and its reference
implementation Jersey.
• Restlet framework
• Spring MVC.
Tutorial Examples
• Spring MVC based:
IBM Developer Works Example
Code Tutor Example
• Jersey Implementation
IBM Developer Works Example
Considerations for SOAP & RESTful
web services
• REST - How to model operations which are verbs like login, logout, transferFunds,
etc? -- think of the resource on which you are applying these methods and use
GET/PUT/POST operations on those resources. Need to map domain operations
into CRUD.
• SOAP doesn't require you to map domain operations onto CRUD.
• SOAP is suited for complex request and responses where multiple objects may get
updated within the same operation.
• REST is particularly useful for mobiles and tablets where there may be a
performance overhead of dealing with SOAP requests.
• SOAP requires less plumbing code than REST services for things like transactions,
security, coordination, addressing, trust, etc.
• SOAP fault handling is richer, REST needs to use HTTP status codes.

More Related Content

What's hot

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
IMC Institute
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
IMC Institute
 
Mule enterprise service bus
Mule enterprise service busMule enterprise service bus
Mule enterprise service bus
Thang Loi
 
Overview of java web services
Overview of java web servicesOverview of java web services
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDB
Apaichon Punopas
 
NiFi - First approach
NiFi - First approachNiFi - First approach
NiFi - First approach
Mickael Cassy
 
Designing REST services with Spring MVC
Designing REST services with Spring MVCDesigning REST services with Spring MVC
Designing REST services with Spring MVC
Serhii Kartashov
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
IMC Institute
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
Vaishali Modi
 
Java Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAPJava Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAP
IMC Institute
 
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
 
Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be used
arya krazydude
 
Dataweave
DataweaveDataweave
Dataweave
krishashi
 
Soa 10 soa technology soap
Soa 10 soa technology soapSoa 10 soa technology soap
Soa 10 soa technology soap
Vaibhav Khanna
 
Java web services
Java web servicesJava web services
Java web services
kumar gaurav
 
Java architecture for xml binding
Java architecture for xml bindingJava architecture for xml binding
Java architecture for xml binding
Kiran Gajbhiye
 
Mule jdbc
Mule   jdbcMule   jdbc
OSOM - Ruby on Rails
OSOM - Ruby on Rails OSOM - Ruby on Rails
OSOM - Ruby on Rails
Marcela Oniga
 

What's hot (20)

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
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
 
Mule enterprise service bus
Mule enterprise service busMule enterprise service bus
Mule enterprise service bus
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Avik_RailsTutorial
Avik_RailsTutorialAvik_RailsTutorial
Avik_RailsTutorial
 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDB
 
NiFi - First approach
NiFi - First approachNiFi - First approach
NiFi - First approach
 
Designing REST services with Spring MVC
Designing REST services with Spring MVCDesigning REST services with Spring MVC
Designing REST services with Spring MVC
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Java Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAPJava Web Services [2/5]: Introduction to SOAP
Java Web Services [2/5]: Introduction to SOAP
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 
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)
 
Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be used
 
Dataweave
DataweaveDataweave
Dataweave
 
Soa 10 soa technology soap
Soa 10 soa technology soapSoa 10 soa technology soap
Soa 10 soa technology soap
 
Java web services
Java web servicesJava web services
Java web services
 
Java architecture for xml binding
Java architecture for xml bindingJava architecture for xml binding
Java architecture for xml binding
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
OSOM - Ruby on Rails
OSOM - Ruby on Rails OSOM - Ruby on Rails
OSOM - Ruby on Rails
 

Similar to Java Web services

Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
Dong Ngoc
 
Linked services
Linked servicesLinked services
Linked services
Carlos Pedrinaci
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
Hong-Jhih Lin
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
karthiksmart21
 
Soa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web servicesSoa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web services
Vaibhav Khanna
 
Unit 2
Unit 2Unit 2
Unit 2
Ravi Kumar
 
Web Service Testing By Sheshadri Mishra
Web Service Testing By Sheshadri MishraWeb Service Testing By Sheshadri Mishra
Web Service Testing By Sheshadri Mishra
Sheshadri Mishra
 
web services-May 25.ppt
web services-May 25.pptweb services-May 25.ppt
web services-May 25.ppt
ShivaangiKrish
 
Xml.ppt
Xml.pptXml.ppt
GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love story
bwullems
 
WIT UNIT-5.pdf
WIT UNIT-5.pdfWIT UNIT-5.pdf
WIT UNIT-5.pdf
jashmithakakavakam
 
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
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemAn Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
Rami Sayar
 
Java Web services
Java Web servicesJava Web services
Java Web servicesvpulec
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Sudha Hari Tech Solution Pvt ltd
 
Oracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node finalOracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node final
Getting value from IoT, Integration and Data Analytics
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 

Similar to Java Web services (20)

Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
Linked services
Linked servicesLinked services
Linked services
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Soa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web servicesSoa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web services
 
Unit 2
Unit 2Unit 2
Unit 2
 
Web Service Testing By Sheshadri Mishra
Web Service Testing By Sheshadri MishraWeb Service Testing By Sheshadri Mishra
Web Service Testing By Sheshadri Mishra
 
web services-May 25.ppt
web services-May 25.pptweb services-May 25.ppt
web services-May 25.ppt
 
Xml.ppt
Xml.pptXml.ppt
Xml.ppt
 
GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love story
 
WIT UNIT-5.pdf
WIT UNIT-5.pdfWIT UNIT-5.pdf
WIT UNIT-5.pdf
 
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
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemAn Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
 
Java Web services
Java Web servicesJava Web services
Java Web services
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
Web services soap rest training
Web services soap rest trainingWeb services soap rest training
Web services soap rest training
 
Oracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node finalOracle application container cloud back end integration using node final
Oracle application container cloud back end integration using node final
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 

More from Sujit Kumar

Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
Sujit Kumar
 
SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database Basics
Sujit Kumar
 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database Security
Sujit Kumar
 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social Applications
Sujit Kumar
 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform Features
Sujit Kumar
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
Sujit Kumar
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
Sujit Kumar
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
Sujit Kumar
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
Sujit Kumar
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
Sujit Kumar
 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
Sujit Kumar
 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data Loader
Sujit Kumar
 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
Sujit Kumar
 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
Sujit Kumar
 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional Features
Sujit Kumar
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String Pool
Sujit Kumar
 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level caches
Sujit Kumar
 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode ContractSujit Kumar
 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and ComparatorSujit Kumar
 

More from Sujit Kumar (20)

Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
 
SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database Basics
 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database Security
 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social Applications
 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform Features
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data Loader
 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional Features
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String Pool
 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level caches
 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode Contract
 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and Comparator
 

Recently uploaded

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 

Java Web services

  • 1. Overview of Java Web Services Sujit Kumar Zenolocity LLC © 2013-2023
  • 2. What are web services • Reusable web application components that provide software functions at a network address over the web with the service always on. • Interoperable between heterogeneous systems (language & platform independent) across the network. • Interface described by WSDL.
  • 3. 2 Types • REST compliant web services. • SOAP based web services.
  • 4. WSDL • Contract between caller and callee that describes a web service using XML format. • Set of operations available at a network address using a specific protocol and data format. • Each operation has an input request message and an output response message.
  • 5. Analogies for a WSDL • WSDL – interface in java. • Operations – static methods in a java object. • Input Message of an operation – argument passed to a java method. • Output Message of an operation – argument returned from a java method. • Types – Classes in Java, without any methods.
  • 6. WSDL Elements • Types – data type definitions • Messages – definition of data being exchanged. • Port Type – set of operations exposed at a network address. • Binding – protocol (SOAP over http) and data format specification.
  • 7. SOAP • XML based communication protocol for accessing Web Services. • Language and Platform Independent. • SOAP provides a way for applications to communicate with each other over HTTP. The applications could be running on different operating systems with different technologies and programming languages.
  • 8. SOAP XML Message Elements • Envelope – wraps everything • Header (optional) • Body – appears after Header. • Fault (optional) – part of the body
  • 9. Example SOAP Message • <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap- encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
  • 10. JAXB • Java Architecture for XML Binding (JAXB) • Two main features: Marshall live java objects into XML data. Un-marshall XML data into live java objects. • Part of the Java SE platform. • One of the APIs in the Java EE platform. • Also, part of the Java Web Services Development Pack (JWSDP).
  • 11. XML, XSD & Tools for JAXB • Analogy: XML is like an object, XSD is like a class or a type. XML should be well formed (syntactically correct) and valid (conform to an XSD). • xjc – convert xsd schemas to java classes. Address.xsd  xjc  Address.java • schemagen – convert annotated java classes to schema definitions. Address.java  schemagen  Address.xsd
  • 12. JAX-WS • Java API for creating web services. • Part of Java EE platform. • Defines a standard for Java-to-WSDL mapping. • Determines how WSDL operations are bound to Java methods. • Determines how SOAP messages are mapped to java method arguments and return values. • Can be used in Java SE from version 6.0.
  • 13. JAX-WS Tools • wsimport : top-down approach. Reads WSDL file & generates portable artifacts that includes SEI (service endpoint implementation), jaxb classes from schema types and exceptions from faults. • wsgen : bottom-up approach. Reads an SEI class and generates the portable artifacts for web service development and deployment. • Both are part of JDK 6 and above.
  • 14. JAX-WS Implementations • Metro Project in Glassfish (open source) • Apache CXF • Apache Axis 2 • Oracle WebLogic • IBM WebSphere • JBossWS • Each of the above provides a wsdltojava utility and provide implementations for the interfaces in the JAX-WS api.
  • 15. Converting WSDL to Java • Vendor provided wsldtojava utilitiy or wsimport utility in JDK 6. • Can be configured to run as an eclipse plugin, or invoked via command line utility or as an ANT/Maven task. • Output of Wsdl2Java is client stubs and skeletons. • Stubs are used to invoke the remote web services, actual business logic is written in the skeletons.
  • 16. Comparison of JAX-WS Implementations • http://wiki.apache.org/ws/StackComparison • http://predic8.com/axis2-cxf-jax-ws- comparison.htm • http://www.ibm.com/developerworks/java/lib rary/j-jws19/index.html
  • 17. Service Oriented Architecture (SOA) • Software architecture design pattern. • Based on discrete pieces of software providing application functionality as services to other applications. • Characteristics of a service: • Service Contract (defined via service description documents) • Loose Coupling (minimize dependencies) • Reusable • Abstraction (hide implementation logic) • Location transparency, discoverable, stateless & composable.
  • 18. SOA and Web Services • Web Services are an implementation of SOA. • SOAP & REST are implementations of Web Services. • Web Service contract exposed via WSDL.
  • 19. Web Services Implementation Mechanisms • Contract First or top-down : create the WSDL first and then generate the stubs and skeletons. WS Consumers use the stubs to invoke the service implemented by the WS Provider in the skeletons. • Contract Last or bottom-up. Implement the business logic first in the WS Provider. Extract WSDL after the implementation. • Contract first is usually preferred.
  • 20. Benefits of Contract First • Looser Coupling between contract and implementation. Implementation logic can be changed without affecting clients. • Easier to keep contracts constant for longer periods of time. Contracts can be fragile and change constantly. In order for a contract to be useful, it must remain constant for as long as possible. • If a contract changes, you will have to contact all of the users of your service, and instruct them to get the new version of the contract. • Enables parallel development of clients and service.
  • 21. RESTful Services • Architectural Style based on HTTP. • Client-Server : separation of responsibilities promotes portable clients & scalable servers. • Stateless – no client context saved on server. • Cacheable – clients can cache responses, improves performance & scalability. • Uniform Interface: identification of resources using URIs. The resources themselves are conceptually separate from the representations that are returned to the client. For example, the server does not send its database, but will send XML or JSON that represents some database records.
  • 22. RESTful Services • Uniform Interface: Manipulation of resources through these representations held by the client. • Uniform Interface: Self-descriptive messages. Each message has enough information to describe how to process the message. • If a service violates any of the required constraints, it cannot be considered RESTful.
  • 23. RESTful Services • Manipulate resources (CRUD) using HTTP methods. • GET – Retrieve • PUT – Create or Update • DELETE – Remove • POST - Create • GET, PUT and DELETE are idempotent, POST is not idempotent. • Idempotent implies: y = f(x), y = f(f(x)), y = f(f(f(x)))
  • 24. Difference between PUT and POST • POST – create a child of the resource identified by the URI. • PUT – create or update the resource identified by the URI.
  • 25. Considerations to use PUT vs POST • Do you name your URL objects you create explicitly, or let the server decide? If you name them then use PUT. If you let the server decide then use POST. • PUT is idempotent, so if you PUT an object twice, it has no effect, then use PUT when possible. • You can update or create a resource with PUT with the same object URI.
  • 26. RESTful Methods applied to single resource or collection of resources STful API HTTP methods Resource GET PUT POST DELETE Collection URI tp://example.com /resources List the URIs and perhaps other details of the collection's members. Replace the entire collection with another collection. Create a new entry in the collection. The new entry's URI is assigned automatically and is usually returned by the operation. Delete the en collection. Element URI tp://example.com resources/item17 Retrieve the specific member of the collection. Replace the addressed member of the collection, or if it doesn't exist, create it. Not generally used. Treat the specific member as a collection & create a new entry in it. Delete the sp member of th collection.
  • 27. Implementations of RESTful web services • Use JSR 311(JAX-RS) and its reference implementation Jersey. • Restlet framework • Spring MVC.
  • 28. Tutorial Examples • Spring MVC based: IBM Developer Works Example Code Tutor Example • Jersey Implementation IBM Developer Works Example
  • 29.
  • 30. Considerations for SOAP & RESTful web services • REST - How to model operations which are verbs like login, logout, transferFunds, etc? -- think of the resource on which you are applying these methods and use GET/PUT/POST operations on those resources. Need to map domain operations into CRUD. • SOAP doesn't require you to map domain operations onto CRUD. • SOAP is suited for complex request and responses where multiple objects may get updated within the same operation. • REST is particularly useful for mobiles and tablets where there may be a performance overhead of dealing with SOAP requests. • SOAP requires less plumbing code than REST services for things like transactions, security, coordination, addressing, trust, etc. • SOAP fault handling is richer, REST needs to use HTTP status codes.