1)What is Web service?
A simple definition for a web service is
A simple definition for a web service is
Web Service is an application or business logic that makes itself available over the internet and is accessible using standard Internet protocols
W3C definition for a web service is
A software system designed to support interoperable machine-to-machine interaction over a network
2)Why you need to learn web services?
Web Service is an application or business logic that makes itself available over the internet and is accessible using standard Internet protocols
W3C definition for a web service is
A software system designed to support interoperable machine-to-machine interaction over a network
2)Why you need to learn web services?
Interoperability
It is not tied to any one operating system or programming language.A java based application on Windows can communicate with a .Net based one on Linux.Web services are browsers and operating system independent service, which means it can run on any browser without the need of making any changes. Web Services take Web-applications to the Next Level
Exposing the Existing Function on the network
Web services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program
Loosely Coupled:
Each service exists independently of the other services that make up the application. Individual pieces of the application to be modified without impacting unrelated areas.
3)Different Favors of Web Services
There are two major categories of web services
- SOAP (Simple Object Access Protocol) Web Service(JAX-WS)
- REST (Representation State Transfer) Web Service(JAXRS)
In simple words SOAP web services uses XML as a mechanism for exchanging of information (one way)
between the two programs (end points) over any transport layer protocol. SOAP
is not relying on any particular programming language or operating system as
far as they understand XML and SOAP message
In REST, every resource is addressed or accessed by Unique URI
(Uniform Resource Identifier) and data and functionality forms a resource
Instead of using XML for request/response, it relies on simple
unique URI and that’s why it is also considered as lightweight alternative to
SOAP. As it is rely on URI as a resource identifier, the standard CRUD
operations of HTTP (GET, PUT, DELETE, POST, HEAD) can be performed on that
URI/resource.
SOAP provides the response in XML format only while REST doesn’t
have to use XML only. Though XML and HTML formats are often used for REST
response, REST can also response in JSON, CSV and RSS formats
4)What are the few example for free and
commercial implementations available for Web
Services?
- Axis 2 (Axis 1 is now obsolete)
- JAX-WS Reference Implementation
- JAX-RS Reference Implementation (Jersey ,RESTeasy.)
- Apache CXF (formerly called XFire)
- JBossWS
- SpringWS
5)SOAP Web Services - Architecture
Role Based Architecture
There are three major roles
within the web service architecture:
- Service Provider
- Service Requestor
- Service Registry
This is the provider of the web service. The service provider implements the service and makes it available on
the Internet.
Service Requestor
This is any consumer of the web
service. The requestor utilizes an existing web service by opening a network
connection and sending an XML request.
Service Registory
This is a logically centralized directory of services.The registry provides a central
place where developers can publish new services or find existing ones.
Protocol Stack-Architecture
Second option for viewing the web service architecture is to examine the emerging web service protocol stack
- Service Transport-This layer is responsible for transporting messages between applications. Currently, this layer includesHyper Text Transport Protocol (HTTP),Simple Mail Transfer Protocol (SMTP),File Transfer Protocol (FTP) etc.
- XML Messaging-This layer is responsible for encoding messages in a common XML format so that messages can be understood at either end. Currently, this layer includes XML-RPC and SOAP.
- Service Description-This layer is responsible for describing the public interface to a specific web service.
- Service Discovery-This layer is responsible for centralizing services into a common registry and providing easy publish/find functionality. Currently, service discovery is handled via Universal Description, Discovery, and Integration (UDDI).
6)Some jargons used in SOAP Web services
WSDL (Web Services Description
Language)
Also maintained by the W3C, WSDL
is an XML-based format for describing Web services.The WSDL document that
describes a Web service acts as a contract between Web service client and server. By adhering to this contact the service provider and consumer are able to
exchange data in a standard way, regardless of the underlying platforms and applications on which they are operating.Through the WSDL, a Web services client learns where a service can be accessed, what operations the service performs, the
communication protocols the service supports, and the correct format for sending messages to the
service.
Primary purpose to describe
The methods(service available)
The Parameter and data type
The network protocols
The location of the web service and how to access it
A WSDL file is an XML
document that describes a Web service using six main elements:
Types – defines the data types (as defined in an XML Schema) used by theservice for sending messages between the client and server.
Message – describes the names and format of the messages supported by service for sending messages between the client and server.
Port type – groups and describes the operations performed by the service through the defined interface.
Service – It is a collection of ports
Port – specifies an address for a binding, i.e., defines a communication port.
Binding – defines the communication protocols supported by the operations provided by the service.
Simple Object Access
Protocol(SOAP):
SOAP is an XML-based protocol from the W3C for exchanging data over
HTTP.
SOAP is mechanism (protocol) for transferring information
(messages) between applications which may be widely distributed.
Web services use SOAP to send
messages between a service and its client(s). Because HTTP is supported by all Web servers and browsers, SOAP messages can be sent
between applications regardless of their platform or programming language. This quality gives Web services their characteristic interoperability.
SOAP messages are XML documents that contain some or all of the
following elements:
- SOAP envelope: It is a root element and wraps the entire soap document
- SOAP header: This optional
element sometime contains application-specific information for the web service
exposed like UsernameToken for security purpose.The header contains additional information to be passed for the web service exposed– like UsernameToken for security purpose
- SOAP body: This is mandatory element of the SOAP envelope and
contains the request information/message for the recipient/client-includes the
message payload.
- SOAP fault: This is used to report errors and child element of SOAP
body, if present. Mostly we can see fault on the response message as either web
service returns well-constructed response message or soap-fault
UDDI(Universal Description, Discovery and Integration )
- UDDI is a standard of the Organization for the Advancement of Structured Information
Standards (OASIS)
- Universal Description, Discovery and Integration (UDDI) is a
directory service. Web services can register with a UDDI and make themselves
available through it for discovery.
- The UDDI allows clients to search this registry, find the intended
service, and retrieve its details
- The Home Page of the UDDI is
http://uddi.xml.org/uddi-org
SOAP Web Service Design
The methods(service available)
The Parameter and data type
The network protocols
The location of the web service and how to access it
Types – defines the data types (as defined in an XML Schema) used by theservice for sending messages between the client and server.
Message – describes the names and format of the messages supported by service for sending messages between the client and server.
Port type – groups and describes the operations performed by the service through the defined interface.
Port type – groups and describes the operations performed by the service through the defined interface.
Service – It is a collection of ports
Port – specifies an address for a binding, i.e., defines a communication port.Binding – defines the communication protocols supported by the operations provided by the service.
Simple Object Access
Protocol(SOAP):
SOAP is an XML-based protocol from the W3C for exchanging data over
HTTP.
SOAP is mechanism (protocol) for transferring information
(messages) between applications which may be widely distributed.
Web services use SOAP to send
messages between a service and its client(s). Because HTTP is supported by all Web servers and browsers, SOAP messages can be sent
between applications regardless of their platform or programming language. This quality gives Web services their characteristic interoperability.
SOAP messages are XML documents that contain some or all of the
following elements:
- SOAP envelope: It is a root element and wraps the entire soap document
- SOAP header: This optional element sometime contains application-specific information for the web service exposed like UsernameToken for security purpose.The header contains additional information to be passed for the web service exposed– like UsernameToken for security purpose
- SOAP body: This is mandatory element of the SOAP envelope and contains the request information/message for the recipient/client-includes the message payload.
- SOAP fault: This is used to report errors and child element of SOAP body, if present. Mostly we can see fault on the response message as either web service returns well-constructed response message or soap-fault
UDDI(Universal Description, Discovery and Integration )
- UDDI is a standard of the Organization for the Advancement of Structured Information Standards (OASIS)
- Universal Description, Discovery and Integration (UDDI) is a directory service. Web services can register with a UDDI and make themselves available through it for discovery.
- The UDDI allows clients to search this registry, find the intended service, and retrieve its details
- The Home Page of the UDDI is http://uddi.xml.org/uddi-org
There are two approaches in implementing a web service and they are
bottom-up and top-down.
Contract last or Bottom Up Approach
Bottom up approach is where we first define the logic of a web
service and then using that we will build the interface. Service code is
written first and then the WSDL is created using the service code.
Contract first or Top Down Approach
Top down is the reverse of bottom up approach first .Here you first define web
service contract. The complete service definition, message format, transport
protocol, security and everything is described in WSDL. Then service is written
after the WSDL. Using that wsdl the skeleton code is generated automatically and after that the
service code is filled up.
A walkthrough examples using SOAP Web Service using JAX-WS
1) Open Eclipse IDE
2) Create java project named " JAX-WSExample "
3) Create new
package named " com.xyz.webservice.jaxws.example "
4) Create JAXWS Service
Endpoint Interface. HelloWorld.java
5) Create JAXWS Service
Endpoint implementation class.
HelloWorldImpl.java
HelloWorldImpl.java
6) Create
Endpoint publisher.
HelloWorldWSPublisher.java
HelloWorldWSPublisher.java
6) Generated
WSDL Verification









No comments:
Post a Comment