Web Services
Web Services
Today, people use the Internet as an everyday service provider for reading headline news,
obtaining stock quotes, getting weather reports, shopping online, and paying bills, and also
for obtaining a variety of information from different sources. These Web-enabled
applications are built using different software applications to generate HTML, and their
access is limited only through an Internet browser or by using an application-specific client.
The emergence of Web services introduces a new paradigm for enabling the exchange of
information across the Internet based on open Internet standards and technologies. Using
industry standards, Web services encapsulate applications and publish them as services.
These services deliver XML-based data on the wire and expose it for use on the Internet,
which can be dynamically located, subscribed, and accessed using a wide range of computing
platforms, handheld devices, appliances, and so on. Due to the flexibility of using open
standards and protocols, it also facilitates Enterprise Application Integration (EAI), business
to-business (B2B) integration, and application-to-application (A2A) communication across
the Internet and corporate intranet. In organizations with heterogeneous applications and
distributed application architectures, the introduction of Web services standardizes the
communication mechanism and enables interoperability of applications based on different
programming languages residing on different platforms.
Web services are based on the concept of service-oriented architecture (SOA). SOA is the
latest evolution of distributed computing, which enables software components, including
application functions, objects, and processes from different systems, to be exposed as
services. According to Gartner research (June 15, 2001), “Web services are loosely coupled
software components delivered over Internet standard technologies.” In short, Web services
are self-describing and modular business applications that expose the business logic as
services over the Internet through programmable interfaces and using Internet protocols for
the purpose of providing ways to find, subscribe, and invoke those services. Based on XML
standards, Web services can be developed as loosely coupled application components using
any programming language, any protocol, or any platform. This facilitatesdelivering business
applications as service accessible to anyone, anytime, at any location, and using any platform.
Consider the simple example shown in Figure 2.1 where a travel reservation services provider
exposes its business applications as Web services supporting a variety of customers and
application clients. These business applications are provided by different travel organizations
residing at different networks and geographical locations.
Traditionally, Web applications enable interaction between an end user and a Web site, while
Web services are service-oriented and enable application to- application communication over
the Internet and easy accessibility to heterogeneous applications and devices. The following
are the major technical reasons for choosing Web services over Web applications:
■Web services can be invoked through XML-based RPC mechanisms across firewalls.
■Web services provide a cross-platform, cross-language solution based on XML messaging.
■Web services facilitate ease of application integration using a lightweight infrastructure
without affecting scalability.
■Web services enable interoperability among heterogeneous applications
● SOA Architecture
Service-oriented architecture (SOA) allows different ways to develop
applications by combining services. The main premise of SOA is to
erase application boundaries and technlogy differences. As
applications are opened up, how we can combine these services
securely becomes an issue. Traditionally, security models have been
hardcoded into applications and when capabilities of an application
are opened up for use by other applications, the security models built
into each application may not be good enough.
What is SOAP:-
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=http://
schemas.xmlsoap.org/soap/envelope/
xmlns:xsi=”http://www.w3c.org/2001/X
MLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/X
MLSchema”
SOAP-ENV:
encodingStyle=”http://schemas.xmlsoap.org/soap/enc ding/”/>
SOAP Header
The SOAP header is represented as the first immediate child element
of a SOAP envelope, and it has to be namespace qualified. In addition,
it also may contain zero or more optional child elements, which are
referred to as SOAP header entries. The SOAP encoding Style
attribute will be used to
define the encoding of the data types used in header element entries.
The SOAP actor attribute and SOAP must Understand attribute can be
used to indicate the target SOAP application node
sender/Receiver/Intermediary) and to process the Header entries.
Listing
<SOAP-E V:Header>
<wiley:Transaction
xmlns:wiley=”http://jws.wiley.com/2002/booktx”
SOAP-E V:mustUnderstand=”1”>
<keyValue> 5 </keyValue>
</wiley:Transaction>
</SOAP-ENV:Header>
27
SOAP Body
A SOAP envelope contains a SOAP body as its child element, and it
may contain one or more optional SOAP body block entries. The
Body represents the mandatory processing information or the
payload intended for the receiver of the message. The SOAP 1.1
specification mandates that there must be one or more optional
SOAP Body entries in a message. A Body block of a SOAP message
can contain any of the following:
■ RPC method and its parameters
<SOAP-ENV:Body>
<m:GetBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList/”>
<bookname xsi:type=’xsd:string’>
</SOAP-ENV:Body>
SOAP Encoding
SOAP 1.1 specifications stated that SOAP- based applications can represent
their data either
as literals or as encoded values defined by the “XML Schema,
Part -2” specification (see ww.w3.org/TR/xmlschema-2/). Literals
refer to message contents that are encoded according to the W3C
XML Schema. Encoded values refer to the messages encoded
based
28
● Web Services Defination Language (WSDL)
<?xml version=”1.0”?>
<definitions name=”BookPrice”
targetNamespace=”http://www.wiley.com/bookprice.wsdl ”
xmlns:tns=http://www.wiley.com/bookprice.wsdl
● WSDL Limitations
If a port type of an operation includes Fault child node, the operation must use
Document
•style.
•The fault part should refer to element but not type. For example:
Supported
<message name="SimpleTypeFault">
<part name="SimpleTypeFault" element="ns2:StringFaultElement" />
</message>
The following is incorrect for faults:
Not Supported
<message name="SimpleTypeFault">
<part name="SimpleTypeFault" type="xs:string" />
</message>
Removing OperationFormatStyle.Rpc Attribute
The OperationFormatStyle.Rpc attribute is not supported if the operation
also has the fault contract attribute.
If the generated proxy code contains an attribute
OperationFormatStyle.Rpc, then you must regenerate the WSDL from the
code after deleting the attribute.
Identical part Elements
The part elements of messages cannot be same. If the elements are
identical, svcutil throws an error. For example, this definition is allowed:
Supported
<message name="MultipartInputElement">
<part name="Fortune" element="ns2:PersonDetailsElementsOne" />
<part name="Person" element="ns2:PersonDetailsElementsTwo" />
</message>
Not Supported
<message name="MultipartInputElement">
<part name="Fortune" element="ns2:PersonDetailsElementsOne" />
<part name="Person" type="xs:string" />
</message>
In the core Web services model, UDDI provides the registry for Web
services to function as a service broker enabling the service providers
to populate the registry with service descriptions and service types
and the service requestors to query the registry to find and locate the
services. It enables Web applications to interact with a UDDI-based
registry using SOAP messages. These registries can be either private
services within an enterprise or a specific community, or they can be
public registries to service the whole global business community of
the Internet. The UDDI working group includes leading technology
vendors like Sun Microsystems, IBM, HP, SAP, Oracle, and
Microsoft.
White Pages
White pages give information about the business supplying the service.
This includes the name of the business and a description of the
business - potentially in multiple languages. Using this information, it
is possible to find a service about which some information is already
known (for example, locating a service based on the provider's
name).[6]
Contact information for the business is also provided - for example the
businesses address and phone number; and other information such as
the Dun & Bradstreet Universal umbering System number.
Yellow Pages
Green pages are used to describe how to access a Web Service, with
information on the service bindings. Some of the information is related
to the Web Service - such as the address of the service and the
parameters, and references to specifications of interfaces.[6] Other
information is not related directly to the Web Service - this includes
e-mail, FTP,CORBA and telephone details for the service. Because a
Web Service may have multiple bindings (as defined in its WSDL
description), a service may have multiple Green Pages, as each binding
will need to be accessed diferently.
● SOAP Vs REST:
● JAXB:
JAXB tutorial provides concepts and API to convert object into XML and XML into object.
Our JAXB tutorial is designed for beginners and professionals.
JAXB stands for Java Architecture for XML Binding. It provides mechanism to marshal
(write) java objects into XML and unmarshal (read) XML into object. Simply, you can say it
is used to convert java object into xml and vice-versa.
● Features of JAXB 2.0
JAXB 2.0 includes several features that were not present in JAXB 1.x. They are as follows:
1) Annotation support: JAXB 2.0 provides support to annotation so less coding is required to
develop JAXB application. The javax.xml.bind.annotation package provides classes and
interfaces for JAXB 2.0.
2) Support for all W3C XML Schema features: it supports all the W3C schema unlike JAXB
1.0.
4) Small Runtime Library: it required small runtime library that JAXB 1.0.