Web Services Digital Notes
Web Services Digital Notes
ON
WEB SERVICES(2005PE11)
IV B.Tech II Semester
PREPARED BY
MALLAREDDYENGINEERINGCOLLEGEFORWOMEN
(AutonomousInstitution-UGC,Govt.ofIndia)
Accredited by NBA & NAAC with ‘A’ Grade, UGC, Govt. of IndiaNIRF
Indian Ranking–2018, Accepted by MHRD, Govt. of India
Permanently Affiliated to JNTUH, Approved by AICTE, ISO 9001:2015 Certified Institution AAAA+
Rated by Digital Learning Magazine, AAA+ Rated by Careers 360 Magazine, 6th RankCSR Platinum
Rated by AICTE-CII Survey, Top 100 Rank band by ARIIA, MHRD, Govt. of IndiaNational Ranking-Top
100 Rank band by Outlook, National Ranking-Top 100 Rank band by Times News Magazine Maisammaguda,
Dhulapally, Secunderabad, Kompally-500100
2023– 2024
SYLLABUS
UNIT I: Evolution and Emergence of Web Services: Evolution of distributed computing, Core
distributed computing technologies, client/server, CORBA, JAVA RMI, Micro Soft DCOM, MOM,
Challenges in Distributed Computing, role of J2EE and XML in distributed computing, emergence ofWeb
Services and Service Oriented Architecture (SOA).
Introduction to Web Services: The definition of web services, basic operational model of web
services, tools and technologies enabling web services, benefits and challenges of using web services.
Web Services Architecture: Web services Architecture and its characteristics, core building blocks of
web services, standards and technologies available for implementing web services, web services
communication, basic steps of implementing web services.
UNIT II:
Fundamentals of SOAP: SOAP Message Structure, SOAP Encoding, Encoding of different data
types, SOAP message exchange models, SOAP communication and messaging, Java and Axis,
Limitations SOAP.
UNIT III:
Describing Web Services:WSDL, WSDL in the world of Web Services, Web Services life cycle,
anatomy of WSDL definition document, WSDL bindings, WSDL Tools, limitations of WSDL.
UNIT IV:
Discovering Web Services: Service discovery, role of service discovery in a SOA, service discovery
mechanisms, UDDI: UDDI Registries, uses of UDDI Registry, Programming with UDDI, UDDI data
structures, Publishing API, Publishing , searching information in a UDDI Registry, limitations of
UDDI.
UNIT V:
Web Services Interoperability:Means of ensuring Interoperability,Overview of.NET,Creating a
.NET Client for an Axis Web Services, Creating Java Client for a web service, Challenges in Web
Services Interoperability.
Services Security:XML security framework,Goals of cryptography,Digital Signature,Digital
Certificate, XML encryption.
TEXTBOOKS:
REFERENCES:
1. Java Web Service Architecture, James McGovern, Sameer Tyagi etal., Elsevier
2. Building Web Services with Java, 2 Edition, S. Graham and others, Pearson Edn.
3. Java Web Services, D.A. Chappell & T. Jewell, O'Reilly,SPD.
4. Web Services, G. Alonso, F. Casati and others, Springer. Outcomes
5. Basic details of WSDL, UDDI. SOAP
6. Implement WS client and server with interoperable systems.
VISION AND MISSION OF THE INSTITUTION
VISION
Visualizing a great future for the intelligentsia by imparting state-of the art
Technologies in the field of Engineering and Technology for the bright future and
prosperity of the students.
To offer world class training to the promising Engineers.
.
MISSION
To nurture high level of Decency, Dignity and Discipline in women to attain high intellectual
abilities.
To produce employable students at National and International levels by effective training
programmes.
To create pleasant academic environment for generating high level learning attitudes.
DEPARTMENT OF INFORMATION TECHNOLOGY
VISION
To emerge as a center of excellence in the department of IT is to empower students with new
wave technologies to produce technically proficient and accomplished intellectual IT
professionals specifically to meet the modern challenges of the contemporary computing
industry and society
Providing the students with most conducive academic environment and making them towards
serving the society with advanced technologies
MISSION
M1: The mission of the department of Information Technology is to afford excellence
education for students, in the conventional and modern areas of information technology and
build up students with high-quality principled trainings, thus manifesting their global
personality development.
M2: To impart holistic technical education using the best of infrastructure, outstanding
technical and teaching expertise
M3: Training the students into competent and confident world class professionals with
excellent technical and communication skills.
M4: To provide quality education through innovative teaching and learning process that yields
advancements in state-of-the-art information technology.
M5:To inculcate the spirit of ethical values contributing to the welfare of the society by
offering courses in the curriculum design.
Course Outcomes:
After completing this course, the student must demonstrate the knowledge and ability to:
Employ the publish, find, bind architecture for Web services and to use the corresponding standards, in
particular. WSDL, SOAP. UDDI
Perform matchmaking on Web services using SOAP.
Develop registration and discovery techniques for Web services
- Implement WS client and server with interoperable system
Index:
UNIT-1...................................................................................................................................................................................................................................... 8
Evolution and Emergence of Web Services .......................................................................................................................................... 8
Evolution of Distributed Computing:- ................................................................................................................................. 8
Importance of Distributed Computing: ...............................................................................................................................9
Client-Server Applications..................................................................................................................................................... 10
CORBA.............................................................................................................................................................................................11
Java RMI......................................................................................................................................................................................... 13
Microsoft DCOM..........................................................................................................................................................................15
Message-Oriented Middleware............................................................................................................................................16
The Emergence of Web Services And Service Oriented Architecture(SOA):...................................................18
Introduction to Web Services:................................................................................................................................................................. 21
Definition of Web Services:....................................................................................................................................................21
Motivation and Characteristics............................................................................................................................................23
Basic Operational Model of Web Services:..................................................................................................................... 25
Tools and Technologies enabling web services:.......................................................................................................... 26
Benefits and Challenges of using web services:........................................................................................................... 28
Key Benefits of Web Services : ............................................................................................................................................. 29
Web services Architecture........................................................................................................................................................................ 30
Web services Architecture and its Core building blocks:.........................................................................................30
Web Services Communication Models:............................................................................................................................ 32
Basic steps of implementing web services:.................................................................................................................... 34
UNIT-2....................................................................................................................................................................................................................................36
Fundamentals of SOAP................................................................................................................................................................................36
SOAP message structure:........................................................................................................................................................36
SOAP ENVELOPE............................................................................................................................................................................................37
SOAP Envelope............................................................................................................................................................................38
SOAP Header................................................................................................................................................................................ 38
SOAP Body.....................................................................................................................................................................................39
SOAP Attachments .....................................................................................................................................................................42
SOAP Encoding ............................................................................................................................................................................................... 43
Multiple References in Arrays ..............................................................................................................................................47
Partially Transmitted Arrays................................................................................................................................................47
Sparse Arrays...............................................................................................................................................................................48
Serialization and Deserialization........................................................................................................................................ 48
SOAP Message Exchange Model.............................................................................................................................................................. 48
SOAP Intermediaries....................................................................................................................................................................................49
SOAP Actor....................................................................................................................................................................................50
SOAP Communication And Messaging ................................................................................................................................................. 50
SOAP RPC .......................................................................................................................................................................................51
SOAP Messaging......................................................................................................................................................................... 52
Java and Axis....................................................................................................................................................................................................52
Installing Axis for Web Services ..............................................................................................................................................................53
Axis Web Services Programming Model..........................................................................................................................55
Creating the Service.................................................................................................................................................................. 55
Creating the Service Requestor........................................................................................................................................... 56
Creating a Normal Service Requestor Client..................................................................................................................56
Creating the Service Requestor Client from WSDL..................................................................................................... 57
Limitations of SOAP......................................................................................................................................................................................59
UNIT-3....................................................................................................................................................................................................................................60
DESCRIBING WEB SERVICES................................................................................................................................................................... 60
Web Services Description Language (WSDL)................................................................................................................60
WSDL in the World of Web Services..................................................................................................................................60
Web Service Life Cycle.............................................................................................................................................................61
Language and Platform Independency of WSDL..........................................................................................................62
Anatomy of a WSDL Definition Document......................................................................................................................................... 62
<definitions>Element...............................................................................................................................................................65
<message>Element................................................................................................................................................................... 66
<portType>Element..................................................................................................................................................................66
<binding>Element..................................................................................................................................................................... 67
<service>Element...................................................................................................................................................................... 67
WSDL Bindings ............................................................................................................................................................................................... 67
WSDL Binding Extensions......................................................................................................................................................67
WSDL Binding Support for Operations............................................................................................................................ 68
SOAP Binding ............................................................................................................................................................................... 68
WSDL Tools...................................................................................................................................................................................................... 71
Limitations of WSDL.................................................................................................................................................................................... 71
UNIT-4....................................................................................................................................................................................................................................72
Discovering Web Services..........................................................................................................................................................................72
Service Discovery.......................................................................................................................................................................72
Role of Service Discovery in SOA........................................................................................................................................ 72
Benefits of SOA Service Registry: ........................................................................................................................................73
SOA Service Discovery............................................................................................................................................................. 73
Benefits of SOA Service Discovery......................................................................................................................................74
Service Discovery Mechanisms............................................................................................................................................................... 74
Universal Description, Discovery and Integration (UDDI):.....................................................................................75
UDDI Registries ...........................................................................................................................................................................75
Public and Private UDDI Registries ....................................................................................................................................75
Uses of UDDI Registry.............................................................................................................................................................. 77
UDDI Specifications...................................................................................................................................................................77
UDDI Programming API.......................................................................................................................................................... 78
Publishing API............................................................................................................................................................................. 79
UDDI Data Structures ...............................................................................................................................................................80
Publishing API.................................................................................................................................................................................................83
Publishing Information to a UDDI Registry....................................................................................................................................... 85
Searching Information in a UDDI Registry ......................................................................................................................88
Programming Steps for Searching......................................................................................................................................88
Programming Steps for Deleting.........................................................................................................................................91
DeleteBusiness.java Source Code........................................................................................................................................92
Compiling and Executing SearchBusiness.java.............................................................................................................94
Limitations of UDDI...................................................................................................................................................................................... 94
UNIT-5....................................................................................................................................................................................................................................95
Web Services Interoperability................................................................................................................................................................. 95
Means of Ensuring Interoperability...................................................................................................................................95
Exposing WSDL...........................................................................................................................................................................95
Creating SOAP Proxies.............................................................................................................................................................96
Testing Interoperability..........................................................................................................................................................96
Overview of .NET ........................................................................................................................................................................96
.NET Framework Class Library............................................................................................................................................97
Creating a .NET Client for Axis Web Services ................................................................................................................ 98
Setting Up the Environment............................................................................................................................................... 100
Creating the Service Provider (Axis Environment)..................................................................................................101
Implementing the Service Provider (ACMEProductCatalog.jws)...................................................................... 102
Obtaining the WSDL of Acme Product Catalog Service...........................................................................................103
Generating a Proxy for the Web Service....................................................................................................................... 103
Compiling the SOAP Proxy as a DLL ................................................................................................................................104
Creating a .NET Client Application.................................................................................................................................. 105
Compiling the Client Application......................................................................................................................................105
Execute and Test the .NET Client from a Windows Environment..................................................................... 106
Challenges in Web Services Interoperability..................................................................................................................................106
Common SOAP/HTTP Transport Issues....................................................................................................................... 106
XML Schema- and XML-Related Issues ..........................................................................................................................107
Version and Compatibility...................................................................................................................................................107
Web Services Security...............................................................................................................................................................................107
XML Security FrameWork:..................................................................................................................................................107
Goals of Cryptography:......................................................................................................................................................... 108
Four Goals of Cryptography ................................................................................................................................................108
Digital Certificates ...................................................................................................................................................................................... 110
XML Encryption....................................................................................................................................................................... 111
What XML Encryption Is...................................................................................................................................................... 111
Implementations of XML Encryption............................................................................................................................. 113
XML Security Suite from IBM (www.alphaworks.ibm.com/tech/ xmlsecuritysuite)...............................113
XML Security Library, Aleksey Sanin (MIT License) (www.aleksey. com/xmlsec/).................................113
Trust Services Integration Kit (TSIK) from Verisign (www.
xmltrustcenter.org/developer/verisign/tsik/index.htm). ...................................................................................113
Phaos XML (www.phaos.com/e_security/prod_xml.html).................................................................................. 113
UNIT-1
Evolution and Emergence of Web Services
servers.
Scalability:
This can be achieved by deploying these reusable distributed components on powerful
servers.
Extensibility:
This can be achieved through dynamic configuration of applications that are distributed
across the network. Higher productivity and lower development cycle time. By breaking
up large problems into smaller ones,these individual components can be enveloped by
smaller development teams in isolation.
components. Reduced cost. Because this World model provide safe use once developed
components that are accessible over the network, significant cost educations can be
achieved.
Reuse. The distributed components may perform various services that can potentially be
used by multiple client applications. It saves repetitive development effort and improves
interoperability between
Distributed computing also has changed the way traditional network programming is
done by providing a shareable object like semantics across networks using programming
languages like Java, C, and C++ . The following sections briefly discuss core distributed
computing technologies such as Client/Server applications, OMG CORBA, Java RMI,
Microsoft COM/DCOM, and MOM.
Client-Server Applications
For example, the client-server model has been widely used in enterprise resource
planning (ERP), billing, and Inventory application systems where a number of client
business applications residing in multiple desktop systems interact with a central
database server.
Figure 1.2 shows an architectural model of a typical client server system in which multiple
desktop-based business client applications access a central database server.
Some of the common limitations of the client-server application model are as follows:
■ Complex business processing at the client side demands robust client systems.
■ Security is more difficult to implement because the algorithms and logic reside on the
CORBA
The Common Object Request Broker Architecture (CORBA) is an industry wide, open
standard initiative, developed by the Object Management Group (OMG) for enabling
distributed computing that supports a wide range of application environments. OMG is a
nonprofit consortium responsible for the production and maintenance of framework
specifications for distributed and interoperable object-oriented systems.
CORBA differs from the traditional client/server model because it provides an object-
oriented solution that does not enforce any proprietary protocols or any particular
programming language, operating system, or hardware platform. By adopting CORBA, the
applications can reside and run on any hardware platform located anywhere on the
network, and can be written in any language that has mappings to a neutral interface
definition called the Interface Definition Language (IDL). An IDL is a specific interface
language designed to expose the services (methods/functions) of a CORBA remote object.
CORBA also defines a collection of system-level services for handling low-level application
services like life-cycle, persistence, transaction, naming, security, and so forth. Initially,
CORBA 1.1 was focused on creating component level, portable object applications without
interoperability. The introduction of CORBA 2.0 added interoperability between different
ORB vendors by implementing an Internet Inter-ORB Protocol (IIOP). The IIOP defines the
ORB backbone, through which other ORBs can bridge and provide interoperation with its
associated services. In a CORBA-based solution, the Object Request Broker (ORB) is an
object bus that provides a transparent mechanism for sending requests and receiving
responses to and from objects, regardless of the environment and its location. The ORB
intercepts the client’s call and is responsible for finding its server object that implements
the request, passes its parameters, invokes its method, and returns its results to the client.
The ORB, as part of its implementation, provides interfaces to the CORBA services, which
allows it to build custom-distributed application environments.
ORB. It acts as the object bus or the bridge, providing the communication infrastructure to
send and receive request/responses from the client and server. It establishes the
foundation for the distributed application objects, achieving interoperability in a
heterogeneous environment. Some of the distinct advantages of CORBA over a traditional
client/server application model are as follows:
Legacy and custom application integration. Using CORBA IDL, developers can
encapsulate existing and custom applications as callable client applications and use them
asobjects on the ORB.
Rich distributed object infrastructure. CORBA offers developers a rich set of distributed
object services, such as the Lifecycle, Events, Naming, Transactions, and Security services.
Location transparency. CORBA provides location transparency: An object reference is
independent of the physical location and application level location. This allows developers
to create CORBA-based systems where objects can be moved without modifying the
underlying applications.
Java RMI
Java RMI was developed by Sun Microsystems as the standard mechanism to enable
distributed Java objects-based application development using the Java environment. RMI
provides a distributed Java application environment by calling remote Java objects and
passing them as arguments or return values. It uses Java object serialization—a
lightweight object persistence technique that allows the conversion of objects into
streams. Before RMI, the only way to do inter-process communications in the Java
platform was to use the standard Java network libraries. Though the java.net APIs
provided sophisticated support for network functionalities, they were not intended to
support or solve the distributed computing challenges.
Java RMI uses Java Remote Method Protocol (JRMP) as the inter process communication
protocol, enabling Java objects living in different Java Virtual Machines (VMs) to
Transparently invoke one another’s methods. Because these VMs can be running on
different computers anywhere on the network, RMI enables object-oriented distributed
computing. RMI also uses a reference-counting garbage collection mechanism that keeps
track f external live object references to remote objects (live connections) using the
virtual machine. When an object is found unreferenced, it is considered to be a weak
reference and it will be garbage collected.
RMI client. The RMI client, which can be a Java applet or a standalone application,
performs the remote method invocations on a server object. It can pass arguments that
are primitive data types orserializable objects.
RMI stub. The RMI stub is the client proxy generated by the rmi compiler (rmic provided
along with Java developer kit—JDK) that encapsulates the network information of the
server and performs the delegation of the method invocation to the server. The stub also
marshals the method arguments and unmarshals the return values from the method
execution.
RMI infrastructure. The RMI infrastructure consists of two layers: the remote reference
layer and the transport layer. The remote reference layer separates out the specific
remote reference behavior from the client stub. It handles certain reference semantics
like connection entries, which are unicast/multicast of the invocation requests. The
transport layer actually provides the networking infrastructure, which facilitates the
actual datatransfer during method invocations, the passing of formal arguments, and the
return of back execution results. RMI skeleton. The RMI skeleton, which also is generated
using the RMI compiler (rmic) receives the invocation requests from the stub and
processes the arguments (unmarshalling) and delegates them to the RMI server. Upon
successful method execution, it marshals the return values and then passes them back to
the RMI stub via the RMI infrastructure.
RMI server. The server is the Java remote object that implements the exposed interfaces
and executes the client requests. It receives incoming remote method invocations from
the respective skeleton, which
passes the parameters after unmarshalling. Upon successful method execution, return
values are sent back to the skeleton, which passes them back to the client via the RMI
infrastructure.
Microsoft DCOM
The Microsoft Component Object Model (COM) provides a way for Windows-based
software components to communicate with each other by defining a binary and network
standard in a Windows operating environment. COM evolved from OLE (Object Linking
and Embedding), which employed a Windows registry-based object organization
mechanism. COM provides a distributed application model for ActiveX components. As a
next step, Microsoft developed the Distributed Common Object
Model (DCOM) as its answer to the
distributed computing problem in the
Microsoft Windows platform. DCOM
enables COM applications to communicate
with each other using an RPC mechanism,
which employs a DCOM protocol on the
wire.
Figure 1.5 shows an architectural model of DCOM. DCOM applies a skeleton and stub
approach whereby a defined interface that exposes the methods of a COM object can be
invoked remotely over a network. The client application will invoke methods on such a
remote COM object in the same fashion that it would with a local COM object. The stub
encapsulates the network location information of the COM server object and acts as a
proxyon the client side. The servers can potentially host multiple COM objects, and when
they register themselves against a registry, they become available for all the clients, who
then discover them using a lookup mechanism.
DCOM is quite successful in providing distributed computing support on the Windows
platform. But, it is limited to Microsoft application environments. The following are some
ofthe common limitations of DCOM:
■ Platform lock-in
■ State management
■ Scalability
■ Complex session management issues
Message-Oriented Middleware
Although CORBA, RMI, and DCOM differ in their basic architecture and approach, they
adopted a tightly coupled mechanism of a synchronous communication model
(request/response). All these technologies are based upon binary communication
protocols and adopt tight integration across their logical tiers, which is susceptible to
scalability issues. Message-Oriented Middleware (MOM) is based upon a loosely coupled
asynchronous communication model where the application client does not
need to know its application recipients or its method arguments. MOM enables
applicationsto communicate indirectly using a messaging provider queue. The application
client sends messages to the message queue (a message holding
area), and the receiving application picks up the
message from the queue. In this operation model, the
application sending messages to another application
continues to operate without waiting for the response
from that application.
■ Most of the standard MOM implementations have provided native APIs for
communication with their core infrastructure. This has affected the portability of
applications across such implementations and has led to a specific vendor lock-in.
■ The MOM messages used for integrating applications are usually based upon a
retrieve data from the information systems with well-defined APIs provided by the
application server.
Integration tier. The Integration tier deals with connecting and communicating to back-
end Enterprise Information Systems (EIS), database applications and legacy applications,
or mainframe applications.
Today, the adoption of the Internet and enabling Internet-based applications has created
a world of discrete business applications, which co-exist in the same technology space but
without interacting with each other. The increasing demands of the industry for
enabling B2B, application-toapplication (A2A), and inter-process application
communication has led to a growing requirement for service-oriented architectures.
Service-oriented architectures are not a new thing. The first service-oriented architecture
for many people in the past was with the use DCOM or Object Request Brokers (ORB s)
based on the CORBA specification. For more on DCOM and CORBA
Services
Connections
The technology of Web Services is the most likely connection technology of service- oriented
architectures. The following figure illustrates a basic service-oriented architecture. It shows a
service consumer at the right sending a service request message to a service provider at the left.
The service provider returns a response message to the service consumer. The request and
subsequent response connections are defined in some way that is understandable to both the
service consumer and service provider. How those connections are defined is explained in Web
Services Explained. A service provider can also be a service consumer.
Metadata:-
Metadata can be defined as a set of assertions about things in our domain of discourse.
Metadata is a component of data, which describes the data. It is "data about data". Often there
is more than that, involving information about data as they is stored or managed, and revealing
partial semantics such as intended use (i.e., application) of data. This information can be of
broad variety, meeting if not surpassing the variety in the data themselves. They may describe,
or be a summary of the information content of the individual databases in an intentional
manner. Some metadata may also capture content independent information like location and
time of creation.
• They enable the abstraction of representational details such as the format and
organization of data, and capture the information content of the underlying data independent of
representational details. This represents the first step in reduction of information overload, as
intentional metadata descriptions are in general an order of magnitude smaller than the
underlying data.They enable representation of domain knowledge describing the information
domain to which the underlying data belong. This knowledge may then be used to make
inferences about the underlying data. This helps in reducing information overload as the
inferences may be used to determine the relevance of the underlying data without accessing the
data.
Fig Types of Metadata in SOA
Metadata can be classified based on different criteria. Based on the level of abstraction in
which a metadata describes content, the metadata can be classified as follows :
• Syntactic Metadata focuses on details of the data source (document) providing little
insight into the data. This kind of metadata is useful mainly for categorizing or cataloguing the
data source. Examples if syntactic metadata include language of the data source, creation date,
title, size, format etc.
• Structural Metadata focuses on the structure of the document data, which facilitates data
storage, processing and presentation such as navigation, eases
• Semantic Metadata describes contextually relevant information focusing on domain-
specific elements based on ontology, which a user familiar with the domain is likely to know or
understand easily. Using semantic metadata, meaningful interpretation of data is possible and
interoperability will then be supported at high-level (hence easier to use), providing meaning to
the underlying syntax and structure.
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 facilitates delivering business applications as a
service accessible to anyone, anytime, at any location, and using any platform.
The following is a typical scenario:
1. The Travel service provider deploys its Web services by exposing the business
applications obtained from different travel businesses like airlines, car-rental, hotel
accommodation, credit card payment, and so forth.
2. The service provider registers its business services with descriptions using a public or
private registry. The registry stores the information about the services exposed by the
service provider.
3. The customer discovers the Web services using a search engine or by locating it
directly from the registry and then invokes the Web ser- vices for performing travel
reservations and other functions over the Internet using any platform or device.
4. In the case of large-scale organizations, the business applications consume these Web
services for providing travel services to their own employees through the corporate
intranet.
■ To enable the publishing of services to one or more public or private directories, thus
enabling potential users to locate the published services using standard-based
mechanisms that are defined by standards organizations
■■ Web services are based on XML messaging, which means that the data exchanged
between the Web service
provider and the user are defined in XML.
■■ Web services provide a cross-platform integration of business applications over the
Internet.
■■ To build Web services, developers can use any common programming language, such
as Java, C, C++, Perl, Python, C# and/or Visual Basic, and its existing application
components.
■■ Web services are not meant for handling presentations like HTML context—it is
developed to generate XML for uniform accessibility through any software application,
any platform, or device.
■■ Because Web services are based on loosely coupled application components, each
component is exposed as a service with its unique functionality.
■■ Web services use industry-standard protocols like HTTP, and they can be easily
accessible through corporate firewalls.
■■ Web services can be used by many types of clients.
■■ Web services vary in functionality from a simple request to a complex business
transaction involving multiple resources.
■■ All platforms including J2EE, CORBA, and Microsoft .NET provide extensive support
for creating and deploying Web services.
■■ Web services are dynamically located and invoked from public and private registries
based on industry standards such as UDDI and ebXML.
Why Use Web Services?
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.
These roles and relationships are defined as follows: Service provider. The service
provider is responsible for developing and deploying the Web services. The provider also
defines the services and publishes them with the service broker. Service broker. The
service broker (also commonly referred to as a service registry) is responsible for service
registration and discovery of the Web services. The broker lists the various service types,
descriptions, and locations of the services that help the service requesters find and
subscribe to the required services. Service requester. The service requester is responsible
for the service invocation. The requester locates the Web service using the service broker,
invokes the required services, and executes it from the service provider.
Tools and Technologies enabling web services:
The five core Web services standards and technologies for building and enabling Web
services are XML, SOAP, WSDL, UDDI, and ebXML
Extensible Markup Language (XML): In February 1998, the Worldwide Web
Consortium (W3C) officially endorsed the Extensible Markup Language (XML) as a
standard data format. XML uses Unicode, and it is structured self-describing neutral data
that can be stored as a simple text document for representing complex data and to make it
readable. Today, XML is the de facto standard for structuring data, content, and data
format for electronic documents. It has already been widely accepted as the universal
language lingua franca for exchanging information between applications, systems, and
devices across the Internet. In the core of the Web services model, XML plays a vital role
as the common wire format in allforms of communication. XML also is the basis for other
Web services standards.
Simple Object Access Protocol (SOAP): Simple Object Access Protocol, or SOAP, is a
standard for a lightweight XML-based messaging protocol. It enables an exchange of
information between two or more peers and enables them to communicate with each
other in a decentralized, distributed application environment. Like XML, SOAP also is
independent of the application object model, language, and running platforms or devices.
In the core of the Web services model, SOAP is used as the messaging protocol for
transport with binding on top of various Internet protocols such as HTTP, SMTP, FTP, and
so on. SOAP uses XML as the message format, and it uses a set of encoding rules for
representing data as messages. Although SOAP is used as a messaging protocol in Web
services, it also can operate on a request/response model by exposing the functionality
using SOAP/RPC based on remote procedural calls. SOAP also can be used with J2EE-
based application frameworks.
ebXML : ebXML defines a global electronic marketplace where enterprises find one
another and conduct business process collaborations and transactions. It also defines a
set of specifications for enterprises to conduct electronic business over the Internet by
establishing a common standard for business process specifications, business information
modeling, business process collaborations, collaborative partnership profiles, and
agreements and messaging. ebXML is an initiative sponsored by the United Nations
Center for Trade Facilitation and Electronic Business (UN/CEFACT) and the Organization
for the Advancement of Structured Information Standards (OASIS). Popular standards
organizations like Open Travel Alliance (OTA), Open Application Group, Inc. (OAGI),
Global Commerce Initiative (GCI), Health Level 7 (HL7, a healthcare standards
organization), and RosettaNet (an XML standards committee) also have endorsed it. In the
Web services model, ebXML provides a comprehensive framework for the electronic
marketplace and B2B process communication by defining standards for business
processes, partner profile and agreements, registry and repository services, messaging
services, and core components. It complements and extends with other Web services
standards like SOAP, WSDL, and UDDI. In particular:
Known Challenges in Web Services Web services present some key challenges associated
with the mission-critical business requirements. These challenges need to be addressed
before the services are fully implemented. Some of the key challenges are as follows:
Distributed transactions:If the environment requires distributed transactions with
heterogeneous resources, it should be studied and tested with standard solutions based
on BTP, WS-Transactions, and WS-Coordination.
Security:Web services are exposed to the public using http-based protocols. As Web
services is publicly available, it must be implemented using authentication and
authorization mechanisms and using SSLenabling encryption of the messages for securing
the usage. Adopting open security standards like SAML, XML Encryption, XML Signature,
or XACML may be a solution. Other challenges include the manageability and testing of
the Web services deployment, which is subjected to different operating system
environments and platforms and managing service descriptions in public/private
registries.
Key Benefits of Web Services :
The key benefits of implementing Web services are as follows:
■■ Provides a simple mechanism for applications to become services that are accessible
by anyone, anywhere, and from any device.
■■ Defines a solution for businesses, which require flexibility and agility in application-
to-application communication over the Internet.
Services registry: The services registry hosts the published services and acts as a broker
providing a facility to publish and store the description of Web services registered by the
service providers. In addition, it defines a common access mechanism for the service
requestors for locating the registered services.
Services delivery.:It acts as the Web services client runtime environment by looking up
the services registries to find the required services and invoking them from the service
provider. It is represented as a presentation module for service requestors, by exposing
the appropriate interfaces or markups for generating content and delivery to a variety of
client applications, devices, platforms, and so forth.
To build the Web services architecture with these logical components, we need to use
standardized components and a communication model for describing and invoking the
services that are universally understood between the service providers and their
potential service requestors. It also requires a standard way to publish the services by the
service provider and store them in the service broker. In turn, service requestors can find
them.
WSDL. This resides in the services container and provides a standardized way to describe
the Web services as a service description. In ebXML-based architecture, ebXML CPP/A
provides services descriptions including business partner profiles and agreements.
UDDI. This provides a standard mechanism for publishing and discovering registered
Web services, and it also acts as the registry and repository to store WSDL-based service
descriptions. In ebXMLbased architecture, ebXML Registry & Repository provides a
facility to store CPP/CPA descriptions for business collaboration.
Web services are accessed using standard Internet protocols and XML—the Web services
architecture forms the standard infrastructure solution for building distributed
applications as services that can be published, discovered, and accessed over the Internet.
Depending upon the implementation, the client can either send or receive a document
asynchronously to and from a messaging-based Web service, but it cannot do both
functionalities at an instant. In addition, it also is possible to implement messaging with a
synchronous communication model where the client makes the service request to the
service provider, and then waits and receives the document from the service provider.
Adopting a communication model also depends upon the Web service provider
infrastructure and its compliant protocol for RPC and Messaging.
The current version of SOAP 1.2 and ebXML Messaging support these communication
models; it is quite important to ensure that the protocols are compliant and supported by
the Web services providers. It also is important to satisfy other quality of services (QoS)
and environmental requirements like security, reliability, and performance.
Basic steps of implementing web services:
1. The service provider creates the Web service typically as SOAPbased service interfaces
for exposed business applications. The provider then deploys them in a service container
or using a SOAP runtime environment, and then makes them available for invocation over
a network. The service provider also describes the Web service as a WSDL-based service
description, which defines the clients and the service container with a consistent way of
identifying the service location, operations, and its communication model.
2. The service provider then registers the WSDL-based service description with a service
broker, which is typically a UDDI registry.
3. The UDDI registry then stores the service description as binding templates and URLs to
WSDLs located in the service provider environment.
4. The service requestor then locates the required services by querying the UDDI registry.
The service requestor obtains the binding information and the URLs to identify the
service provider.
5. Using the binding information, the service requestor then invokes the service provider
and then retrieves the WSDL Service description for those registered services. Then, the
service requestor creates a client proxy application and establishes communication with
the service provider using SOAP.
6. Finally, the service requestor communicates with the service provider and exchanges
data or messages by invoking the available services in the service container.
In the case of an ebXML-based environment, the steps just shown are the same, except
ebXML registry and repository, ebXML Messaging, and ebXML CPP/CPA are used instead
of UDDI, SOAP, and WSDL, respectively. The basic steps just shown also do not include the
implementation of security and quality of service (QoS) tasks.
UNIT-2
Fundamentals of SOAP
SOAP message structure:
SOAP defines the structure of an XML document, rules, and mechanisms that can be used to enable
communication between applications. It does not mandate a single programming language or a
platform, nor does it define its own language or platform..
The example shown in Listing 4.1 is a SOAP request/response message for obtaining book price
information from a book catalog service provider.
The SOAP request accepts a string parameter as the name of the book and returns a float as the
price of the book as a SOAP Response.
<SOAP-ENV:Envelope
xmlns:SOAP ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3c.org/2001/XMLSchema”
SOAP-ENV:encodingStyle
=”http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Header>
<person:mail
xmlns:person=”http://acmeco.com/Header/”>[email protected]
</person:mail>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:GetBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList”>
<bookname xsi:type=’xsd:string’>
Developing Java Web Services</bookname>
</m:GetBookPrice>
</SOAP-ENV:Body>
</SOAP-ENV: Envelope>
In the scenario in Listing 4.1, the SOAP message is embedded in an HTTP request for getting the
book price information from www.wiley.comfor the book Developing Java Web Services.
Listing 4.2 shows the SOAP message embedded in an HTTP responsereturning the price
of the book.
HTTP/1.1 200 OK
Content-Type: text/xml; charset=”utf-8”
Content-Length: 640
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3c.org/2001/XMLSchema”
SOAP-ENV:
encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”/>
<SOAP-ENV:Header>
<wiley:Transaction
xmlns:wiley=”http://jws.wiley.com/2002/booktx”
SOAP-ENV:mustUnderstand=”1”> 5
</wiley:Transaction>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:GetBookPriceResponse xmlns:m=”
http://www.wiley.com/jws.book.priceList”>
<Price>50.00</Price>
</m:GetBookPriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP ENVELOPE
■■ http://schemas.xmlsoap.org/soap/envelope/ (SOAP 1.1)
■■ http://www.w3.org/2001/06/soap-envelope (SOAP 1.2)
SOAP ENCODING
■■ http://schemas.xmlsoap.org/soap/encoding/ (SOAP 1.1)
■■ http://www.w3.org/2001/06/soap-encoding (SOAP 1.2)
Additionally, SOAP also can use attributes and values defined in W3C XML Schema instances or
XML Schemas and can use the elements based on custom XML conforming to W3C XML Schema
specifications. SOAP does not support or use DTD-based element or attribute declarations.
Typical to the previous example message, the structural format of a SOAP message (as per
SOAP version 1.1 with attachments) contains the following elements:
■■ Envelope
■■ Header (optional)
■■ Body
■■ Attachments (optional)
Figure 4.1 represents the structure of a SOAP message with attachments.Typically, a SOAP
message is represented by a SOAP envelope with zero or more attachments. The SOAP
message envelope contains the header and body of the message, and the SOAP message
attachments enable the mes-sage to contain data, which include XML and non-XML data
(like text/binary files). In fact, a SOAP message package is constructed using the MIME
Multipart/Related structure approaches to separate and identify thedifferent parts of the
message.
SOAP Body
Attachment
Body entry
Attachment Body entry
Attachment
Attachment
SOAP Envelope
The SOAP envelope is the primary container of a SOAP message’s structure and is the
mandatory element of a SOAP message. It is represented as the root element of the
message as Envelope. As we discussed earlier, it is usually declared as an element using
the XML namespace http://schemas.xmlsoap.org/soap/envelope/.
As per SOAP 1.1 specifications, SOAP messages that do not follow this namespace
declaration are not processedand are considered to be invalid. Encoding styles also can be
defined usinga namespace under Envelope to represent the data types used in the
message. Listing 4.3 shows the SOAP envelope element in a SOAP message.
</SOAP-ENV:Envelope>
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 asSOAP header entries. The SOAP encodingStyle
attribute will be used to define the encoding of the data types used in header element
entries. The SOAP actor attribute and SOAP mustUnderstand attribute can be usedto
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
SOAP-ENV:
encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”/>
<SOAP-ENV:Header>
<wiley:Transaction
xmlns:wiley=”http://jws.wiley.com/2002/booktx”
SOAP-ENV:mustUnderstand=”1”>
<keyValue> 5 </keyValue>
</wiley:Transaction>
</SOAP-ENV:Header>
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 repre- sents 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
■■ Target application (receiver) specific data
■■ SOAP fault for reporting errors and status information
Listing 4.5 illustrates a SOAP body representing an RPC call for getting the book price
information from www.wiley.com for the book name Devel-oping Java Web Services.
<SOAP-ENV:Body>
<m:GetBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList/”>
<bookname xsi:type=’xsd:string’>
Developing Java Web services</bookname>
</m:GetBookPrice>
</SOAP-ENV:Body>
Like other elements, the Body element also must have a qualified name- space and be associated
with an encodingStyle attribute to provide the encoding conventions for the payload. In general,
the SOAP Body can con- tain information defining an RPC call, business documents in XML, and
any XML data required to be part of the message during communication.
SOAP Fault
In a SOAP message, the SOAP Fault element is used to handle errors and to find out status
information. This element provides the error and/or sta- tus information. It can be used within a
Body element or as a Body entry.
It provides the following elements to define the error and status of the SOAP message in a
readable description, showing the source of the infor- mation and its details:
Faultcode:The faultcode element defines the algorithmic mecha- nism for the SOAP application to
identify the fault. It contains stan- dard values for identifying the error or status of the SOAP
application. The namespace identifiers for these faultcode values are defined in
http://schemas.xmlsoap.org/soap/envelope/. The following fault- code element values are
defined in the SOAP 1.1 specification:
VersionMismatch:This value indicates that an invalid namespace is defined in the SOAP envelope
or an unsupported version of a SOAP message.
MustUnderstand:This value is returned if the SOAP receiver node cannot handle and recognize
the SOAP header block when the MustUnderstand attribute is set to 1. The MustUnderstand
values can be set to 0 for false and 1 for true.
Client: This faultcode is indicated when a problem originates from the receiving client. The
possible problems could vary from an incorrect SOAP message, a missing element, or incorrect
name- space definition.
Server: This faultcode indicates that a problem has been encoun- tered during processing on the
server side of the application, and that the application could not process further because the
issue is specific to the content of the SOAP message.
Faultstring: The faultstring element provides a readable descrip- tion of the SOAP fault exhibited
by the SOAP application.
Faultactor: The faultactor element provides the information about the ultimate SOAP actor
(Sender/Receiver/Intermediary) in the message who is responsible for the SOAP fault at the
particular destination of a message.
Detail: The detail element provides the application-specific error or status information related to
the defined Body block.
The common examples of SOAP fault scenarios:
How a SOAP Fault Is Represented in a SOAP Message
Listing 4.6 shows how a SOAP Fault is represented in a SOAP message.
<SOAP-ENV:Envelope xmlns:SOAP-ENV
=”http://schemas.xmlsoap.org/soap/envelope/”
SOAP-ENV:encodingStyle=
“http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:MustUnderstand</faultcode>
<faultstring>Header element missing</faultstring>
<faultactor>http://jws.wiley.com/GetBookPrice</faultactor>
<detail>
<wiley:error
xmlns:wiley=”http://jws.wiley.com/GetBookPrice”>
<problem>The Book name parameter missing.</problem>
</wiley:error>
</detail>
</SOAP-ENV:Fault>
</SOAP_ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Fault>
<faultcode> SOAP-ENV:Server</faultcode>
<faultstring> Server OS Internal failure - Reboot server</faultstring>
<faultactor>http://abzdnet.net/net/keysoap.asp</faultactor>
</SOAP-ENV:Fault>
Listing 4.8 shows how a SOAP Fault is caused due to client failure.
<SOAP-ENV:Fault>
<faultcode>Client</faultcode>
<faultstring>Invalid Request</faultstring>
<faultactor>http://jws.wiley.com/GetCatalog</faultactor>
</SOAP-ENV:Fault>
<SOAP-ENV:Header>
<wiley:Catalog
xmlns:wiley=”http://jws.wiley.com/2002/bookList”
SOAP-ENV:mustUnderstand=”1”>
</wiley:Catalog>
</SOAP-ENV: Header>
SOAP Attachments
As per SOAP 1.1 with the attachment specification, a SOAP message con- tains the primary SOAP
envelope in an XML format and SOAP attachments in any data format that can be ASCII or binary
(such as XML or non-text). SOAP attachments are not part of the SOAP envelope but are related to
the message.
As the SOAP message is constructed using a MIME multipart/related structure, the SOAP
attachment part of the message is contained to a MIME boundary (defined in the Context-Type
header). Each MIME part in the structure of the SOAP message is referenced using either Content-
ID or Content-Location as labels for the part. Both the SOAP header and body of the SOAP
message also can refer to these labels in the message. Each attachment of the message is
identified with a Content-ID (typically an href attribute using a URL scheme) or Content-Location
(a URI reference associated to the attachment).
Listing 4.11 uses “WileyCoverPage.gif” as an attachment and illustrates the use of the Content-ID
(CID) reference in the body of the SOAP 1.1 mes- sage using absolute URI-referencing entities
labeled for using Content- Location headers.
MIME-Version: 1.0
Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml;
start=”<http://jws.wiley.com/coverpagedetails.xml>”
Content-Description: SOAP message description.
--MIME_boundary--
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <http://jws.wiley.com/coverpagedetails.xml>
Content-Location: http://jws.wiley.com/coverpagedetails.xml
--MIME_boundary--
Content-Type: image/gif
Content-Transfer-Encoding: binary
Content-ID: <http://jws.wiley.com/DevelopingWebServices.gif>
Content-Location: http://jws.wiley.com/DevelopingWebServices.gif
Although the SOAP 1.1 specification addressed the SOAP attachments based on MIME
Multipart/related, the W3C Working Group also is evaluating the support of MIME
Application/Multiplexed-based attachments that facilitate the attachment binary data of the
message can be interleaved from the XML contents of the message. To find out more information
on the latest specification of SOAP attachments, refer to www.w3.org/TR/SOAP-attachments.
SOAP Encoding
The SOAP encoding defines a set of rules for expressing its data types. It is a generalized set of
data types that are represented by the programming languages, databases, and semi-structured
data required for an application. SOAP encoding also defines serialization rules for its data model
using an encodingStyle attribute under the SOAP-ENV namespace that specifies the serialization
rules for a specific element or a group of elements.
2.3Encoding Different Data types:
SOAP encoding supports both simple- and compound-type values.
Simple Type Values
The definition of simple type values is based on the “W3C XML Schema, Part -2: Datatypes”
specification. Examples are primitive data types such as string, integer, decimal, and derived
simple data types including enumeration and arrays. The following examples are a SOAP
representation of primitive data types:
<int>98765</int>
<decimal> 98675.43</decimal>
<string> Java Rules </string>
The derived simple data types are built from simple data types and are expressed in the W3C
XML Schema.
Enumeration:Enumeration defines a set of names specific to a base type. Listing 4.12 is an
example of an enumeration data type expressed in a W3C XML Schema.
MIME-Version: 1.0
Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml;
start=”<http://jws.wiley.com/coverpagedetails.xml>”
Content-Description: SOAP message description.
--MIME_boundary--
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <http://jws.wiley.com/coverpagedetails.xml>
Content-Location: http://jws.wiley.com/coverpagedetails.xml
--MIME_boundary--
Content-Type: image/gif
Content-Transfer-Encoding: binary
Content-ID: <http://jws.wiley.com/DevelopingWebServices.gif>
Content-Location: http://jws.wiley.com/DevelopingWebServices.gif
<myfigure xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:enc=” http://schemas.xmlsoap.org/soap/encoding”>
xsi:type=”enc:base64”>
sD334G5vDy9898r32323</myfigure>
<price xsi:type=”xsd:float”>1000.99</price>
And, the XML instance of the price data type will be as follows:
<price>1000.99</price>
Compound Type Values
Compound value types are based on composite structural patterns that represent member values
as structure or array types. The following sec- tions list the main types of compound type values.
Structure Types
Listing 4.14 is an XML Schema of the Structure data type representing the “Shipping address”
with subelements like “Street,” “City,” and “State.”
<xs:element name=”ShippingAddress”
xmlns:xs=”http://www.w3.org/2001/XMLSchema” >
<xs:complexType>
<xs:sequence>
<xs:element ref=”Street”type=”xsd:string”/>
<xs:element ref=”City” type=”xsd:string”/>
<xs:element ref=”State” type=”xsd:string”/>
<xs:element ref=”Zip” type=”xsd:string”/>
<xs:element ref=”Country” type=”xsd:string”/>
</xs:sequence>
</xs:complexType>
</xs:element>
<e:ShippingAddress>
<Street>1 Network Drive</Street>
<City>Burlington</City>
<State>MA</State>
<Zip>01803</Zip>
<Country>USA</Country>
</e:ShippingAddress>
Listing 4.16 Structure data type using simple and complex types.
Array Types
Listing 4.17 is an XML Schema of an Array data type representing
MyPortfolio — a list of portfolio stock symbols.
<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”
xmlns:enc=”http://schemas.xmlsoap.org/soap/encoding” >
<xs:import
namespace=”http://schemas.xmlsoap.org/soap/encoding” >
<xs:element name=”MyPortfolio” type=”enc:Array”/>
</xs:schema>
<MyPortfolio xmlns:xs=”http://www.w3.org/2001/XMLSchema”
xmlns:enc=” http://schemas.xmlsoap.org/soap/encoding”
enc:arrayType=”xs:string[5]”>
<symbol>SUNW</symbol>
<symbol>IBM</symbol>
<symbol>HP</symbol>
<symbol>RHAT</symbol>
<symbol>ORCL</symbol>
</MyPortfolio>
<MyProducts xmlns:xs=”http://www.w3.org/2001/XMLSchema”
xmlns:enc=”
http://schemas.xmlsoap.org/soap/encoding”
enc:arrayType=”xs:string[][3]”>
<item href=”#product-hw”/>
<item href=”#product-sw”/>
<item href=”#product-sv”/>
<SOAP-ENC:Array id=”product-hw”
SOAP-ENC:arrayType=”xsd:string[3]”>
<item>SUN Blade 1000</item>
<item>SUN Ultra 100</item>
<item>SUN Enterprise 15000</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id=”product-sw”
SOAP-ENC:arrayType=”xsd:string[2]”>
<item>Sun Java VM</item>
<item>Sun Solaris OS</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id=”product-sv”
SOAP-ENC:arrayType=”xsd:string[2]”>
<item>Sun Java Center services</item>
<item>Sun Java Web Services</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array SOAP-ENC:arrayType=”xsd:string[6]”
SOAP-ENC:offset=”[2]”>
<item> No: 2</item>
<item> No: 3</item>
<item> No: 4</item>
<item> No: 5</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array SOAP-ENC:arrayType=”xsd:int[10]”>
<SOAP-ENC:int SOAP-ENC:position=”[0]”>0</SOAP-ENC:int>
<SOAP-ENC:int SOAP-ENC:position=”[10]”>9</SOAP-ENC:int>
</SOAP-ENC:Array>
SOAP Intermediaries
SOAP defines intermediaries as nodes for providing message processing and protocol routing
characteristics between sending and receiving appli- cations. Intermediary nodes reside in
between the sending and receiving nodes and process parts of the message defined in the SOAP
header. The two types of intermediaries are as follows:
Forwarding intermediaries:This type processes the message by describing and constructing the
semantics and rules in the SOAP header blocks of the forwarded message.
Active intermediaries:This type handles additional processing by modifying the outbound
message for the potential recipient SOAP nodes with a set of functionalities.In general, SOAP
intermediaries enable a distributed processing model to exist within the SOAP message exchange
model. By using SOAP intermediaries, features can be incorporated like store and forward,
intelligent routing, transactions, security, and logging, as well as other value additions to SOAP
applications.
SOAP Actor
In a SOAP message to represent a target SOAP node, the SOAP actor global attribute with a URI
value can be used in the Header element. SOAP defines an actor with a URI value, which identifies
the name of the SOAP receiver node as an ultimate destination. Listing 4.22 is an example of a
SOAP actor attribute.
<SOAP-ENV:Envelope xmlns:SOAP-
ENV=”http://schemas.xml.org/soap/envelope/”
SOAP-ENV:encodingStyle=”http://schemas.xml.org/soap/encoding/”/>
<SOAP-ENV:Header>
<b:Name xmlns:t=”http://www.wiley.com/BookService/”
SOAP-ENV:actor=”http://www.wiley.com/jws/”
SOAP-ENV :mustUnderstand=”1”>
WebServices</b:Name >
</SOAP-ENV:Header>
<SOAP:Body> <m:NewBook xmlns:m=”http://www.wiley.com/Books”>
<BookName>Developing Java Web services</BookName>
</m:NewBook>
</SOAP:Body>
</SOAP:Envelope>
4.23 is an example of a SOAP message that is forwarded via two SOAP intermediaries before the
final receiving node.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3c.org/2001/XMLSchema”
SOAP-ENV:encodingStyle
=”http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:GetBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList”>
<bookname xsi:type=’xsd:string’>
Developing Java Web services</bookname>
</m:GetBookPrice>
</SOAP-ENV:Body>
</SOAP-ENV: Envelope>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=”http://www.w3c.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3c.org/2001/XMLSchema”
SOAP-ENV:encodingStyle
=”http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:GetBookPrice
xmlns:m=”http://www.wiley.com/jws.book.priceList”>
<bookname xsi:type=’xsd:string’>
Developing Java Web services</bookname>
</m:GetBookPrice>
</SOAP-ENV:Body>
</SOAP-ENV: Envelope>
</m:GetBookPriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP Messaging
SOAP Messaging represents a loosely coupled communication model based on message
notification and the exchange of XML documents. The SOAP message body is represented by XML
documents or literals encoded according to a specific W3C XML schema, and it is produced and
con- sumed by sending or receiving SOAP node(s). The SOAP sender node sends a message with
an XML document as its body message and the SOAP receiver node processes it.
Listing 4.26 represents a SOAP message and a SOAP messaging-based communication. The
message contains a header block InventoryNotice and the body product, both of which are
application-defined and not defined by SOAP. The header contains information required by the
receiver node and the body contains the actual message to be delivered.
<env:Envelope xmlns:env=”http://www.w3.org/2001/12/soap-envelope”>
<env:Header>
<n:InventoryNotice xmlns:n=”http://jws.wiley.com/Inventory”>
<n:productcode>J6876896896</n:productcode>
</n: InventoryNotice>
</env:Header>
<env:Body>
<m:product xmlns:m=”http://jws.wiley.com/product”>
<m:name>Developing Java Web Services</m:name>
<m:quantity>25000</n:quantity>
<m:date>2002-07-01T14:00:00-05:00</n:date>
</m:product>
</env:Body>
</env:Envelope>
2.In a messaging-based communication model, the client sends an XML document and the server
application receives the XML as a W3C Document object for processing. It is not mandatory for
the service to send a response back to the client. In case of sending a response, the service
returns a W3C Document object as a body of the SOAP response message. The following snippet
is a method that receives a purchase order XML as a W3C document for processing. Upon
successful processing, it sends out a response message as a W3C document with the shipping
notice, otherwise it sends out a product availability status notice.
public Document sendPODocument (Document poXML)
throws Exception {
// process purchase order
boolean processPO = submitPurchaseOrder(poXML);
if (processPO) {
//TRUE: create Shipping notice Document doc = getShippingDoc(poXML);
}
else
// FALSE: create product availability status Document doc =
getAvailabilityStatus(poXML); return doc;
}
Creating the Service Requestor
Axis allows service clients to be created in two different ways:
1.Having the required values for locating and invoking the service provider, such as SOAP,
endpoint of the service, methods, parameters, and so on
2.Using a WSDL-based service description exposed by the service provider
The programming steps involved in creating the service client with all of the required
parameters and how to invoke the service exposed by the provider.
In case of a messaging-based communication model, the key program- ming steps involved for
creating the service client are as follows:
1.Import the Axis packages, the most important ones of which are the following:
import org.apache.axis.client.Service; import org.apache.axis.client.Call; import
org.apache.axis.message.*; import org.apache.axis.*;
import java.net.URL;
import org.apache.axis.utils.XMLUtils; import org.w3c.dom.*;
2.Define the endpoint of the service:
String endpoint =
“http://localhost:8080/axis/services/HelloMSG”;
3.Read the XML document as an input stream or string:
InputStream is =
ClassLoader.getSystemResourceAsStream(“hello.xml”);
4.Create a new service:
Service service = new Service();
5.Create a SOAP request call using the service:
Call call = (Call) service.createCall();
6.Set the target endpoint of the provider location:
call.setTargetEndpointAddress( endpoint );
7.Create a SOAP envelope with an XML payload:
SOAPEnvelope env = new SOAPEnvelope(is);
8.Send the SOAP envelope with an XML payload to the destination:
call.invoke(env);
9.In case of obtaining a response message, the response message also will be a W3C
document as well:
SOAPEnvelope elems = (SOAPEnvelope)call.invoke(env);
It also is possible to create service clients dynamically using dynamic invocation interfaces
provided by JAX-RPC. This is discussed further in Chapter 10, “Building RPC Web Services with
JAX-RPC.”
To understand how to create Axis service clients from WSDL, refer to the full-featured example in
Chapter 3, “Building the Web Services Architecture.”
Axis Deployment Model
Axis facilitates easy deployment and undeployment of services using XML- based Web services
deployment descriptors (WSDDs). It enables deploying and undeploying services and also Axis-
specific resources like handlers and chains using an administration utility ‘AdminClient’ provided
as part of the Axis toolkit.
To deploy a service, ensure that the AXIS CLASSPATH is set and run the following command:
The deploy.wsdd refers to the deployment descriptor defining the ser- vice, classes, methods,
provider (RPC or Messaging), and its namespaces.
Listing 4.36 is a sample WSDD to deploy a service in an Axis environment.
<deployment name=”test”
xmlns=”http://xml.apache.org/axis/wsdd/”
xmlns:java=”http://xml.apache.org/axis/wsdd/providers/java”
xmlns:xsd=”http://www.w3.org/2000/10/XMLSchema”
xmlns:xsi=”http://www.w3.org/2000/10/XMLSchema-instance”>
Listing 4.36 Web services deployment descriptor (WSDD) for deploying a service.
The previous WSDD defines HelloService using a provider with an RPC-based communication
model by exposing its class jws.ch4.helloservice.HelloService and its method justSayHello. The
deployment name test is an identifier and the namespaces define the W3C XML schemas
associated with the implementation.
Similarly, to undeploy a service, ensure that the AXIS CLASSPATH is set and then run the
following command:
<undeployment name=”test”
xmlns=”http://xml.apache.org/axis/wsdd/”
xmlns:java=”http://xml.apache.org/axis/wsdd/providers/java”
xmlns:xsd=”http://www.w3.org/2000/10/XMLSchema”
xmlns:xsi=”http://www.w3.org/2000/10/XMLSchema-instance”>
<service name=” HelloService “/>
</undeployment>
Listing 4.37 Web services deployment descriptor (WSDD) for undeploying a service.
Additionally, to find out the list of services deployed in the Axis envi- ronment, run the following
command:
java org.apache.axis.client.AdminClient list
This command will list all the services deployed in an Axis environment. It also is possible to
deploy and undeploy the services in an Axis environment by editing the server-config.xml file
located at AXIS_HOME directory.
Limitations of SOAP
SOAP (Simple Object Access Protocol) is a protocol used for exchanging structured information in
the implementation of web services. Some of its limitations include:
1. *Complexity:* SOAP can be complex due to its XML-based structure, making it more
challenging for human readability and requiring additional bandwidth for transmission
compared to other lightweight protocols.
2. *Performance:* The XML format used in SOAP messages can sometimes lead to larger message
sizes, resulting in increased bandwidth usage and slower performance compared to more
compact protocols like REST.
3. *Overhead:* Due to its adherence to strict standards and formalities, SOAP can have higher
overhead in terms of processing, which can impact performance, especially in scenarios where
efficiency is critical.
4. *Tight Coupling:* SOAP tends to create tightly coupled systems due to its strict definition of
message formats, making it more challenging to evolve and modify services without affecting
clients.
5. *Less Support for Web Browsers:* SOAP was initially designed with remote procedure calls in
mind and is not as well-suited for browser-based applications as other protocols like REST,
which can use HTTP methods directly.
6. *Limited Compatibility:* While SOAP provides a well-defined standard for communication
between applications, ensuring compatibility across different platforms and languages can
sometimes be a challenge.
These limitations have led to the development and adoption of alternative web service protocols
like REST (Representational State Transfer) that offer more flexibility and simplicity in many
cases.
UNIT-3
In Figure 5.1, all of the communication over the wire takes place on SOAP. The following
list explains the steps depicted in Figure 5.1:
Step 1 illustrates a service provider publishing its Web service to a UDDI registry.
This is when the service provider would create a WSDL definition and publish a link
to this definition along with the rest of the Web service information to a UDDI registry.
Step 2 illustrates an interested service user locating the Web service and finally
obtaining information about invoking the Web service from the published WSDL
definition. This step involves downloading a WSDL definition to the service user
system and deserializing WSDL to a Java class (or any other language). This Java
interface serves as a proxy to the actual Web service. It consists of the binding
information of the Web service.
Step 3 shows the service user binding at runtime to the Web service. In this step, the
service user’s application would make use of the Java interface representing WSDL as
a proxy, in order to bind to the Web service.
Step 4 finally shows the service user invoking the Web service based on the service
invocation information it extracted from the Web service WSDL definition. This is
when the service user’s application would make use of the Java interface representing
WSDL as a proxy, in order to invoke the methods/functions exposed by the Web
service.
WSDL is capable of describing Web services that are implemented using any language
and deployed on any platform. Thus, WSDL contributes toward enabling interoperability
in the Web service architecture. In other words, as long as a WSDL definition can be
understood and consumed by the service user, the service user systems can obtain all of
the information necessary to invoke a Web service potentially developed and deployed
using a completely different set of platform tools and servers. Now, let’s see what a typical
WSDL document looks like and understand its structural elements.
A WSDL definition document consists of the following seven key structural elements:
<definitions>. A WSDL document is a set of definitions. These definitions are
defined inside the element, which is the root element in a WSDL document. It defines
the name of the Web service and also declares the namespaces that are used
throughout the rest of the WSDL document.
<types>. This element defines all of the data types that would be used to describe
the messages that are exchanged between the Web service and the service user.
WSDL does not mandate the use of a specific typing system. However, as per the
WSDL specification, XML Schema is the default typing system. XML Schema was
discussed in Chapter 4, “Developing Web Services Using SOAP,” in the context of SOAP
encoding.
<message>. This element represents a logical definition of the data being
transmitted between the Web service and the service user. This element describes a
one-way message, which may represent a request or response sent to or from the
Web service. It contains zero or more message elements, which basically refer to the
request parameters or response return values.
<prototype>. This element defines the abstract definition of the operations
supported by a Web service, by combining various request and response messages
defined by elements. Each operation refers to an input message and an output
message.
<binding>. This element specifies a concrete protocol and data format used for
representing the operations and messages defined by a particular , on the wire.
<port> . This element specifies an address for binding to the Web service.
<service>. This element aggregates a set of related elements, each which uniquely
specify the binding information of the Web service. A consisting of multiple elements
essentially represents the capability of the service to be invoked over multiple
bindings. More information on WSDL bindings is discussed in the next section.
We will further examine each of these elements later. First, let’s take a look at Listing 5.1,
which shows a WSDL document describing a weather information Web service,
WeatherInfoService. This WSDL definition is present in the WeatherInfo.wsdl file.
Now, let’s understand how exactly WeatherInfo.wsdl describes the WeatherInfoService
Web service.
<definitions>Element
The <definitions>element specifies the name of the document in which this WSDL
definition is stored, which is WeatherInfo in our case. This element specifies namespaces
that would be used in the rest of the WSDL document. The following are the two
important namespaces that the<definitions> element defines:
<portType>Element
The <portType>element in WeatherInfo.wsdl defines a single operation named
GetWeatherInfo by combining the <input>message as defined by the
GetWeatherInfoInput <message>element and the<output> message as defined by the
GetWeatherInfoOutput<message> element. Note the use of WeatherInfo.wsdl as a target
namespace by the <input> and <output> elements.
Four types of operations are supported by WSDL:
One-way operation. One-way operation represents a service that just receives the
message, and thus a one-way operation is typically defined by a single <input> message
element.
Request-response operation. A request-response operation represents a service that
receives a request message and sends a response message. Typically, a request-response
operation is defined by one <input> message followed by one<output> message. An
optional <fault> element also can be included in the definition of a requestresponse
operation to specify the abstract message format for any error messages that may be
output as a result of the operation.
The GetWeatherInfo operation follows the request-response transmission pattern.
Solicit-response operation. A solicit-response operation represents a service that sends
a request message and that receives the response message. Such operations are therefore
<service>Element
The <service>element specifies the location of the service. Because our
WeatherInfoService is bound to SOAP, we use the element and specify the service URL as
http://myweather.com /provideweatherinfo/.
WSDL Bindings
In WSDL, the term binding refers to the process of associating protocol or data format
information with an abstract entity such as <message>,<operation> , or <portType> . In
this section, we examine the support for bindings in the WSDL 1.1 specification. Let’s
begin with the WSDL binding extensions.
SOAP Binding
WSDL 1.1 defines a binding for SOAP 1.1 endpoints. This binding provides the following
SOAP protocol specific information:
An indication that the binding is bound to the SOAP 1.1 protocol
A way of specifying an address for a SOAP endpoint
The URI for the SOAP action HTTP header for the HTTP binding of SOAP
A list of definitions of headers that are transmitted as part of the SOAP envelope
Let’s examine the SOAP binding of the request-response RPC operation over HTTP as
defined in the WeatherInfo.wsdl file shown earlier (see the section titled Anatomy of a
WSDL Definition Document).
<soap:binding>
<soap:operation>
The <soap:operation>element is defined in WeatherInfo.wsdl as follows:
This element defines how the message elements appear inside the SOAP body element.
Based on the style of communication, RPCoriented or document-oriented, the element of
the SOAP message is constructed.
The use attribute indicates whether the message elements are encoded using some
encoding rules or whether the elements already define the concrete schema of the
message.
If the value of the use attribute is “encoded”, then each message refers to an abstract type
defined through the type attribute. These abstract types are then used to produce a
concrete definition of the message by applying the encoding specified by an encodingStyle
attribute.
WSDL Tools
WSDL tools typically provide functionality in terms of the following:
WSDL generation. Generating WSDL from an existing service component—for example, a
J2EE component or a Java Bean component or from scratch.
WSDL compilation. A typical WSDL compiler would generate the necessary data
structures and a skeleton for the implementation of the service. The generated
implementation skeleton contains all the methods (operations) that are described in the
given WSDL definition.
WSDL proxy generation. This functionality can read a WSDL and produce a specific
language binding (for example, Java or Perl) consisting of all the code required to bind the
Web service and to invoke the Web service functions at runtime. This functionality is
typically used at the client end.
Many WSDL tools provide support for these three functionalities. Table 5.1 lists some of
the famous ones in the Java Web Services space.
Limitations of WSDL
WSDL does not support one-way messaging (Single-mode). It requires both output and
input.
It does not permit overload operations.
All operations need to be of one kind, i.e., either all doc/literal or RPC-encoded.
It does not support SOAP-encoded structures and SOAP-encoded arrays.
There is no support for output mapping (header in response).
WSDL focuses solely on SOAP operations and disregards HTTP and MIME operations.
WSDL cannot include more than one element of <wsdl:include> (cannot have more than one
file).
UNIT-4
Discovering Web Services
Service Discovery
Web services discovery provides access to software systems over the Internet using
standard protocols. In the most basic scenario there is a Web Service Provider that
publishes a service and a Web Service Consumer that uses this service.
Web Service Discovery is the process of finding suitable web services for a given
task.Universal Description, Discovery, and Integration (UDDI) is an XML-based registry for
business internet services.
Publishing a Web service involves creating a software artifact and making it accessible to
potential consumers. Web Service Providers augment a Web service endpoint with an
interface description using the Web Services Description Language (WSDL) so that a
consumer can use the service.
Optionally, a provider can explicitly register a service with a Web Services Registry such
as Universal Description Discovery and Integration (UDDI) or publish additional
documents intended to facilitate discovery such as Web Services Inspection Language
(WSIL) documents. The service users or consumers can search Web Services manually or
automatically. The implementation of UDDI servers and WSIL engines should provide
simple search APIs or web-based GUI to help find Web services.
Web services may also be discovered using multicast mechanisms like WS-Discovery, thus
reducing the need for centralized registries in smaller networks.
Service Repository is where metadata of services and related SOA artifacts, such as
policies can be stored.
Managing the Service life-cycle and visibility to all SOA assets with their related
artefacts.
Service discovery is the process of locating web service providers, and retrieving web
services descriptions that have been previously published. The primary mechanism
involved in performing of Service Discovery is a service registry, which contains relevant
metadata about available and upcoming services as well as pointers to the corresponding
service contract documents that can include SLAs.
In modern architectures nodes come and go and you need to decouple individual service
instances from the knowledge of the deployment topology of your architecture.
After the discovery process is complete, the service developer or client application should
know the exact location of a Web service (URI), its capabilities, and how to interface with
it.
Benefits of SOA Service Discovery
Discovery of the service, its status, and its owner will be critical to achieve the
benefits of SOA re usability.
Dynamic service registration and discovery becomes much more important in these
scenarios in order to avoid service interruption.
Handling Fail over of service instances
Traditionally, the Web service discovery processes involved manual interference. A set of
Web service descriptions is discovered according to user requirements. These service
descriptions are manually scanned and those services which satisfy user requirements are
selected and composed. In distributed system integration environment, such manual
intervention is impractical, cumbersome and time consuming. The approaches to Web
services discovery can be classified as centralized and decentralized. UDDI falls under
fully centralized approach that supports replication where central registries are used to
store Web service descriptions. Having realized that replicating the UDDI data is not a
scalable approach several decentralized approaches have been proposed. Two major
operators, namely IBM and Microsoft provide public UDDI service. Web service discovery
mechanisms include a series of registries, indexes, catalogues, agent based and Peer to
Peer P2P solutions. The most dominating among them is the Universal Description
Discovery and Integration-UDDI standard that is currently in version 3.
Universal Description, Discovery and Integration (UDDI):
UDDI enables the businesses providing services (in electronic form or in any other
medium) to register information to enable the discovery of their services and business
profile by prospective customers and/or partners. Similarly, it enables businesses to
discover other businesses for expanding potential business partnerships. Thus, UDDI
presents businesses with an opportunity to step into new markets and services. It powers
all kinds of businesses, large, medium, or small, to accelerate their business presence in
this global market. UDDI initially started as a joint effort from IBM, Microsoft, and Ariba.
Since then, a number of companies joined the UDDI community. As of this book’s writing,
the UDDI project community is looking forward to releasing version 3.0 of the UDDI
specification.
UDDI Registries
An implementation of the UDDI specification is termed as a UDDI registry. UDDI registry
services are a set of software services that provide access to the UDDI registry. Meanwhile,
registry services can perform a plethora of other activities such as authenticating and
authorizing registry requests, logging registry requests, load-balancing requests, and so
on.
Public and Private UDDI Registries
A UDDI registry can be operated in two modes: public mode and private mode. A public
UDDI registry is available for everyone to publish/query the business and service
information on the Internet. Such public registries can be a logical single system built
upon multiple UDDI registry nodes that have their data synchronized through replication.
Thus, all the UDDI reg- istry node operators would each host a copy of the content and
accessing any node would provide the same information and quality of service as any
other operator node. Such global grouping of UDDI registry nodes is known as a UDDI
Business Registry, or UBR. Content can be added into a UBR from any node, however,
content can be modified or deleted only at a node at which it was inserted.
A private UDDI registry is operated by a single organization or a group of collaborating
organizations to share the information that would be avail- able only to the participating
bodies. Private UDDI registries can impose additional security controls to protect the
integrity of the registry data and to prevent access by unauthorized users. Note that a
private node also can participate in information replication.
A UDDI registry in itself is a Web service. A Web service consumer queries the UDDI
registry using the SOAP API defined by UDDI specifica- tion. Also, the UDDI specification
publishes a WSDL description of the UDDI registry service.
The UDDI project community members operate a UBR. This registry is available to
everyone for free publishing/querying of businesses and ser- vices information. To find
more information on this publicly operated UDDI registry, visit the UDDI Web site at
www.uddi.org.
■■ <find_business>
■■ <find_relatedBusinesses>
■■ <find_service>
■■ <find_binding>
■■ <find_tModel>
To get further detailed information from the UDDI registry, the following inquiry API
functions are available:
■■ <get_businessDetail>
■■ <get_businessDetailExt>
■■ <get_serviceDetail>
■■ <get_bindingDetail>
■■ <get_tModelDetail>
Publishing API
The publishing API consists of functions represented by a UDDI Schema, which defines
XML messages that can be used to create, update, and delete the information present in a
UDDI registry. Note that in order to publish to a UDDI registry, the registry user needs to
be authenticated.
The following is a list of publishing API functions that can be used for adding/modifying
information to a UDDI registry:
■■ <save_business>
■■ <set_publisherAssertions>
■■ <add_publisherAssertions>
■■ <save_service>
■■ <save_binding>
■■ <save_tModel>
The following is a list of publishing API functions that can be used for deleting information
from a UDDI registry:
■■ <delete_business>
■■ <delete_publisherAssertions>
■■ <delete_service>
■■ <delete_binding>
■■ <delete_tModel>
Apart from the functions just mentioned, the publishing API also defines functions that
deal with the authentication of the registry users, which is required in order to
successfully execute the rest of the functions of this API:
■■ <get_authToken>
■■ <discard_authToken>
The XML messages constituting the UDDI programmer APIs are defined using a UDDI XML
Schema. These XML messages are wrapped in a SOAP message and then sent to the UDDI
registry. In other words, all of the XML messages are enveloped within a SOAP <body>
element and then sent as an HTTP POST request to the UDDI registry. The UDDI registry
then processes these SOAP messages and gets hold of the actual API function represented
by the XML message, which further instructs the registry ser- vices to provide either
publishing or querying services.
A UDDI registry node typically enables access to both inquiry and publishing
functionalities through different access point URLs. Table 5.3 lists the URLs for publicly
operated UDDI registry nodes.
As we can see from Table 5.3, all of the URLs corresponding to the pub- lishing access
points support HTTPS, because publishing operations need authenticated access.
Table 5.3 Access Point URLs
Note that all the UDDI invocations follow a synchronous request/response mechanism
and are stateless in nature. This statelessness has a significant impact on the
authentication of a registry user to the UDDI registry, which is required when performing
a publishing operation on the registry. Because of the stateless nature of the UDDI
programming API, each time a registry user uses a publishing programming API, the
security credentials of the identity associated with the registry user also are passed with
each UDDI invocation.
<tModel>
The <tModel> structure provides a description of a particular specification or behavior of
the service. The <tModel> structure does not contain the service specification directly;
instead, it contains a link to the service specification, which is managed elsewhere. The
<tModel> thus defines the interaction pattern in order to use the service. For example, a
business may provide a Web service whose WSDL interface may be referenced through a
link from within the <tModel> structure.
Thus, <tModel> defines the lowest-level and most concrete piece of information about the
services offered by a business. A UDDI client typi- cally gets hold of the service
specification pointed out by the <tModel> structure in order to use a publicly available
Web service registered by a particular business.
The linking between these five core data structures of UDDI is depicted in Figure 5.4.
Apart from these five primary data structures, two other structures exist that represent
the category and identification information of the primary data structures:
<identifierBag> and <categoryBag>.
<identifierBag>
The <identifierBag> structure enables <businessEntity> or
<tModel> structures to include information about the common forms of identification
such as D-U-N-S numbers and tax IDs. This data can be used to signify the identity of
<businessEntity>, or it can be used to signify the identity of the publishing party.
Including such identification informa- tion is optional. However, when a published
<businessEntity> or <tModel> carries such common forms of identification, it greatly
enhances the search behaviors exposed via inquiry API functions.
<categoryBag>
The<categoryBag>structure enables<businessEntity>,
<businessService>, and <tModel> structures to be categorized according to any categorization
system, such as an industry categorization system or a geography categorization system.
Categorizing the data structures mentioned previously is optional. However, when these data
structures are published along with their categorization information, it greatly enhances the
search behaviors exposed via inquiry API functions.
Publishing API
Publishing to a UDDI registry requires an authenticated access. UDDI specification does
not define authentication mechanisms, and hence, authentication is dependent upon the
implementations of UDDI. Also, a URL different from an inquiry URL usually handles
publishing-related API calls. Typically, HTTPS is used for carrying publishing call
request/response information.
Table 5.9 lists the publishing API functions as well as their semantics. The table also lists
the structure that is returned in response to each of these function calls.
Table 5.9 Publishing API Functions (continued)
Publishing Information to a UDDI Registry
SubmitBusiness.java shows us how to publish a business named ACME Computer Services
along with its description. In the coming sections, we will examine the source code of
SubmitBusiness.java, followed by its compilation and execution.
Programming Steps for Publishing
The entire publishing logic is provided by the doSubmit() method of the
jws.ch5.SubmitBusiness class, and hence, its implementation is of most interest to us. The
following are the steps of doSubmit():
1. Construct the UDDIApiPublishing object. This is the object that we will use to actually
publish to the registry.
2. Get hold of the authentication token from the registry with the help of the
get_authToken() API call on the UDDIApiPublishing object. Once we have the
authentication token, we should be able to publish to the registry.
3. Create the BusinessEntity structure and populate it with the name and description of
the business to submit. Note that we do not have to create the key for this business
because the registry, upon submitting the business information, would generate it.
4. Now, get hold of the SaveBusiness object. This object represents a collection of
businesses that we wish to submit at a time. Hence, we will need to add the
BusinessEntity object that we just created to the SaveBusiness object using the
addBusinessEntity() method.
5. Now, publish the business information through a save_busi- ness() call on
UDDIApiPublishing object. This method call takes the SaveBusiness object as an
argument and returns the BusinessDetail object upon completion.
6. After the publishing operation has been executed, discard the authen- tication token.
Finally, check whether the publishing operation was successful or not.
7.
SubmitBusiness.java Source Code
Listing 5.5 shows the complete code listing of SubmitBusiness.java.
package jws.ch5;
import org.idoox.uddi.client.api.v2.*;
import org.idoox.uddi.client.api.v2.request.publishing.*; import
org.idoox.uddi.client.structure.v2.business.*; import
org.idoox.uddi.client.structure.v2.base.*;
import org.idoox.uddi.client.api.v2.response.*; import org.idoox.uddi.*;
doSubmit();
}
System.out.println(“Name: “ + sBusinessName);
System.out.println(“Description: “ + sBusinessDescription);
UDDIApiPublishing objUDDIApiPublishing =
UDDILookup.getPublishing(“https://www.systinet.com:443
/wasp/uddi/publishing/”);
}
else
{
System.err.println(“\nSuccessful in submitting the new business information to
registry.”);
}
return;
}
}
package jws.ch5;
import org.idoox.uddi.client.api.v2.request.inquiry.*;
import org.idoox.uddi.client.structure.v2.tmodel.*;
import org.idoox.uddi.client.structure.v2.base.*;
import org.idoox.uddi.client.api.v2.response.*;
import org.idoox.uddi.client.structure.v2.business.*;
import org.idoox.uddi.client.api.v2.*;
import org.idoox.uddi.*;
// criteria
if (objBusinessList==null)
{
System.err.println(“No businesses were found matching the
criteria.”);
}
else
{
// Get hold of the BusinessInfo objects,
// contained by BusinessList BusinessInfos objBusinessInfos =
objBusinessList.getBusinessInfos();
System.out.println(“\n” + objBusinessInfos.size() +
“ businesses found matching the criteria...\n”);
System.out.println(“Business UUID = “ +
objBusinessInfo.getBusinessKey());
System.out.println(“----------------
---------------------------------”);
>javac jws/ch5/SearchBusiness.java
package jws.ch5;
import org.idoox.uddi.*;
import org.idoox.uddi.client.api.v2.*;
import org.idoox.uddi.client.api.v2.request.publishing.*;
import org.idoox.uddi.client.api.v2.response.*;
import org.idoox.uddi.client.structure.v2.business.*;
doDelete(objBusinessKey);
}
}
UDDIApiPublishing objUDDIApiPublishing =
UDDILookup.getPublishing(“ https://www.systinet.com:443/wasp/uddi/pu
blishing/”);
System.out.println(
objDispositionReport.toXML());
}
}
}
}
Compiling and Executing SearchBusiness.java
The following command line instruction compiles DeleteBusiness
.java:
>javac jws/ch5/DeleteBusiness.java
Limitations of UDDI
UDDI is an evolving standard. Currently, the most deployed version of UDDI (2.0) is limiting in
terms of the information model that it supports, especially when compared to other registry
specifications such as ebXML Registry/Repository. UDDI provides support for storing only the
basic data structures, such as businesses, users, services, and service technical descriptions.
However, storing information about business Web services requires more than just the basic
support. For example, potential users of business Web services should be able to publish/query
extensive business- oriented information, such as the business process models that a particular
business Web service relies upon. This is possible only if the target registry provides a data
structure representing the business process model. Thus, an information model is an important
feature for any registry. Registry information model, are further discussed in Chapter 11, “Java
API for XML Registries.”
Also, UDDI is just a registry as opposed to ebXML Registry/Repository, which is, as the name
suggests, a registry as well as repository. The basic difference between a registry and repository is
that a registry holds just the metadata of the objects submitted, whereas a repository actually
stores the submitted objects.
UNIT-5
Web Services Interoperability
Exposing WSDL
Most Web services platforms and SOAP implementations provide this as an automatic mechanism
by delivering WSDL for all its exposed services. The exposed WSDL defines the service provider
information and service specific parameters required by a service requestor for invoking the ser-
vices, which enables the building service clients to interact with the service provider, thus
ensuring interoperability based on the WSDL. The service clients also can be dynamically
generated from a service provider’s WSDL lookup. In such cases, the SOAP client runtime
implementation must pro- vide those dynamic invocation services.
Creating SOAP Proxies
For a Web service, the client SOAP proxies can be created manually or can be generated
dynamically based on the WSDL provided details of the service provider. In the automatic
generation of SOAP proxies, sometimes they may throw SOAP faults during service invocation and
may require some modifications in the SOAP headers or the encoded RPC calls. In most cases, this
problem occurs due to non-conforming WSDL and SOAP implementation in the infrastructure of
the service provider or requestor.
Testing Interoperability
To ensure that interoperability between the service provider and requestor exists, the underlying
SOAP implementations also can be tested. In that case, the SOAP implementations of the service
provider and the requestor must agree and conform to the following SOAP-specific dependencies:
■■ The defined SOAP transport protocol bindings (like http)
■■ The supported version of SOAP (like SOAP 1.1 or SOAP 1.2)
■■ The version of WSDL from the service provider and its ability to support by the service
requestor client
■■ The version of W3C XML Schema supported by the SOAP message, especially the SOAP
envelope and its body elements
Most Web services platforms and SOAP implementation providers test their products among
SOAP implementations using a standard test suite. This suite can be used to ensure
interoperability with other SOAP imple- mentations for conformance testing.
To explore the concepts, let’s experiment with an interoperability sce- nario using a Java-based
Web services implementation to interact with a Microsoft-based service client implementation. To
try out this scenario, we have chosen to use Apache Axis as the Java-based Web services provider
and the Microsoft .NET Framework as the client Web services requestor.The development and
deployment of a Web services requestor is done in a unique part of the Microsoft .NET platform.
Like any other Web services platform providers, the Microsoft .NET Framework typically supports
industry-standard protocols and technologies, including XML, SOAP, WSDL, and UDDI.
Overview of .NET
Microsoft .NET is part of the Microsoft .NET platform—Microsoft’s strategy for developing
distributed applications through XML Web services. The Microsoft .NET Framework provides a
full-fledged development environ- ment for developing XML Web services in a Microsoft
Windows–based environment. It facilitates a runtime infrastructure and APIs for developing Web
services applications using a variety of object-oriented programming languages such as C#, Visual
Basic, and so forth. The .NET Framework pro- vides the infrastructure for defining the
overall .NET platform. Microsoft provides .NET compilers that generate a new code referred to as
Microsoft Intermediate Language (MSIL). MSIL is a CPU-independent code instruc- tion, which is
able to run on any system supporting its native machine language. The .NET compilers provided
by Microsoft are as follows:
■■ VB.NET (Visual Basic for .NET)
■■ C++ .NET (Visual C++ for .NET)
■■ ASP.NET (Microsoft ASP for .NET)
■■ C# .NET (New language for .NET)
■■ JScript (Jscript for .NET)
The Microsoft .NET Framework consists of two core components
Common Language Runtime (CLR)
The Common Language Runtime, or CLR, provides a managed runtime environment (.NET Engine)
for the .NET Framework. CLR enables appli- cations to install and execute code, and it provides
services such as mem- ory management, including garbage collection, threading, exception
handling, deployment support, application runtime security, versioning, and so on.
CLR provides a set of JIT (just-in-time) compilers, which compile MSIL to produce native code
specific to the target system. CLR defines a set of rules as Common Type System (CTS) and
Common Language System (CLS) that specifies the .NET-supported languages required to use for
developing compilers supporting a .NET platform. This enables the com- piler vendors to
develop .NET-compliant compilers and to perform cross- language integration. Cross language
integration enables .NET-compliant languages to run and interact with one another in a .NET
environment.
PointBase
Figure 6.1 Apache Axis and Microsoft .NET-based Web services infrastructure.
Figure 6.1 represents the Web services infrastructure involving Apache Axis and the Microsoft .NET
Framework.
To understand the problem and flow of events, the sequence diagram in Figure 6.2 illustrates the various
sequences of actions performed by a .NET client invoking the ACME Web services deployed in the Axis-
based Web services environment.
Based on the previous sequence of events, we have chosen to use an AcmeXMLHelper class to act as a proxy
by encapsulating the business functionalities, which include database interaction, XML construction, XML
parsing operations, and so forth. More specifically, the AcmeXML- Helper class will handle all of the XML
construction tasks and AcmeDAO will handle the database interaction.
Figure 6.3 depicts the class diagram of the server-side components to sup- port the ACME Web service
provider using the Apache Axis infrastructure. To try out this example, download the chapter-specific
source code and documentation available at www.wiley.com/compbooks/nagappan. The source code and
README text for installing and running this example are
available as part of chapter-6.zip.
Now, let’s take a look at how to set up the development environment and implementation of those service
components.
.NETServiceRequestor Axis Service provider environment
Return ACME
Product catalog data
Create ACME
Value object
We will be creating the Acme product catalog service as ACMEProduct Catalog.jws, which will be
acting as the service provider in the Axis environment.
The ACMEProductCatalog.jws class uses AcmeXMLHelper and AcmeDAO as helper classes for XML
processing and database interaction. The ACMEProductCatalog.jws then will be deployed in the
Axis envi- ronment as an Axis JWS service.
Now, let’s take a closer look at the implementation and walk through the code of
ACMEProductCatalog.jws .
Implementing the Service Provider (ACMEProductCatalog.jws)
The source code implementation for ACMEProductCatalog.jws is shown in Listing 6.1.
// AcmeProductCatalog.jws
import jws.ch4.xmlhelper.AcmeXMLHelper;
{ String pc;
AcmeXMLHelper axh;
try {
// Instantiate the AcmeXMLhelper
axh = new AcmeXMLHelper();
// Call method
pc = axh.getProductCatalogXMLasString();
} catch (Exception e)
{ e.printStackTrace();
}
// Return the response string
return pc;
}
}
The next step is to use the WSDL.exe utility to generate proxy client classes from the
ACME service provider WSDL. To create the proxy client classes, run the following
command from your Windows command prompt (in a single line):
wsdl.exe /l:CS
/protocol:SOAP http://localhost:8080/axis/AcmeProductCatalog?WSDL
/out:AcmeServiceClient.cs
This command creates AcmeServiceClient.cs as a proxy class for the ACME product
catalog service, as shown in Figure 6.5.
Listing 6.2 shows the generated C# source code.
//
// This source code was auto-generated by wsdl, Version=1.0.3705.0.
//
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“code”)]
[System.Web.Services.WebServiceBindingAttribute(
Name=”AcmeProductCatalogSoapBinding”,
Namespace=”http://localhost:8080/axis/AcmeProductCatalog.jws”)] public
class AcmeProductCatalogService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
[System.Web.Services.Protocols.SoapRpcMethodAttribute (“”,
RequestNamespace=”getProductCatalog”,
ResponseNamespace=
“http://localhost:8080/axis/AcmeProductCatalog.jws”)]
[return:
System.Xml.Serialization.SoapElementAttribute(“return”)] public string
getProductCatalog() {
object[] results = this.Invoke
(“getProductCatalog”, new object[0]); return ((string)(results[0]));
}
This command creates a DLL library file which acts as a proxy stub class for the client, as shown in Figure
6.6.
csc.exe /r:AcmeServiceClient.dll
/t:exe
/out:AcmeServiceClientApp.exe AcmeServiceClientApp.cs
This command creates AcmeServiceClientApp.exe, which is an executable .NET client application file that
invokes the ACME service provider, as shown in Figure 6.7.
using System;
namespace AcmeServiceClient {
public class AcmeServiceClientApp {
public AcmeServiceClientApp() {
}
public static void Main () {
Finally, to invoke the ACME product catalog from the ACME service provider (Axis
environment), run the .NET client application AcmeSer- viceClientApp.exe from the
command prompt.
If everything works successfully, you will get the output shown in Figure 6.8.
This summarizes our Web service interoperability example scenario involving Apache
Axis-based Java Web services and the Microsoft .NET Framework.
The challenges that affect interoperability in Web services will be exam- ined in the
following sections.
Common SOAP/HTTP Transport Issues
At the core of Web services, the transport protocols establish the communi- cation and
enable the services to send and receive messages. In case of using HTTP protocol, if the
service provider requires a SOAPAction with a null value, most HTTP clients may not be
able to provide a SOAPAction with a null value. The possible solutions are to fix the
service client APIs and to ensure that certain service provider implementations require
SOAP- Action with a null value. To solve these problems, test the client to see if they can
handle those scenarios.
XML Schema- and XML-Related Issues
XML schema validation handling causes a lot of interoperability issues among SOAP
implementations. So defining data types using XMS schema definitions must occur in both
the service client and provider implementations.
Some SOAP implementations specify the encoding of data as UTF-8 and UTF-16 in the
Content-Type header as
And some implementations do not specify the charset in the Content- Type header, which
causes some SOAP implementations to be unable to process messages. To correct this
problem, ensure that the SOAP implemen- tation and its encoding standards are
compliant with the W3C specifications.
SOAP/XML Message Discontinuities
Message discontinuities cause a major problem between a SOAP imple- mentation in
fulfilling the request and response between the service client and service provider. To
overcome these issues, ensure that the application is aware of the message discontinuities
and throw SOAPFaults in the case of missing elements in the SOAPBody of the request
message.
Version and Compatibility
The version of the supported XMLSchema, and the SOAP and WSDL spec- ifications, and
its compatibility between SOAP implementations affect interoperability. To ensure that
these issues are handled, the Web services platform providers and its SOAP
implementations must be tested for the compatible versions of XML Schema definitions
and the SOAP and WSDL specifications.
The emergence of the WS-I initiative, which is examined in the next sec- tion, will address
these issues as part of its goals.
Digital Signatures
A user can use a public/private key to sign a message. A digital signature is akin to its
physical counterpart, the handwritten signature, in that the sender digitally signs a
message so that the recipient can verify that the message really came from the sender.
Digital signatures also provide for an integrity check. That is, they ensure that the
message has not been tam- pered with after it was signed.
The process of digitally signing a message involves creating a hash for the message and
encrypting this hash using the sender’s private key. Finally, the message is sent with the
encrypted hash. On receiving the mes- sage and the encrypted hash, the recipient would
decrypt the hash using the sender’s public key. This confirms that the message arrived
from the sender and no one else (non-repudiation). Also, by re-computing the hash of the
arrived message and then comparing it with the decrypted hash, the recipient can verify
that the message has not been changed since it was signed (an integrity check).
Figure 13.3 depicts a scenario where Alice sends her digital signature along with the
message that she sends to Bob.
As can be seen from Figure 13.3, a digital signature does not involve encrypting the actual
message. The actual message is sent as is along with the encrypted hash that serves as the
digital signature. Thus, in order to protect the message from eavesdroppers while in
transit, anyone can either encrypt the message and then digitally sign it or they can
digitally sign the message first and then encrypt it. Either method should be usable. The
result is an encrypted message with an encrypted hash that only the intended recipient is
able to read. This scenario thus yields confidentiality, non-repudiation, as well as integrity
in communication.
Two popular algorithms for digital signatures are RSA and Digital Sig- nature Algorithm
(DSA). Support for both of these algorithms is provided in XML Encryption as well as XML
Signature specifications.
Digital Certificates
A key by itself does not contain any binding information, such as to whom the key
belongs to, who issued the key, and the period over which it is valid. Without this
supporting information, there is no way that one can link a particular key with its actual
owner. Digital certificates provide an exact means to describe this supporting information
that binds a user with a specific public key. Putting this into context in our Alice and Bob
exam- ple, if Alice wanted to get Bob’s public key to send him an encrypted mes- sage, she
would first get hold of Bob’s digital certificate that confirms Bob’s identity and contains
his public key.
Now this raises another issue: How can Alice be sure that she has retrieved Bob’s genuine
certificate and not that of his imposter? This is when Certificate Authority (CA) comes into
picture. The CA acts as a trusted third party for the certificates. A CA is supposed to verify
the iden- tity of an individual or business, before it issues a digital certificate. A CA
manages the process of certificate creation, issuance, and revocation. At the time of
certificate creation, a CA signs the digital certificate with its own private key. So now
when Alice receives Bob’s digital signature that has been digitally signed by a CA’s private
key, she takes for granted that the identity of Bob has been verified by that CA and that
she is interacting with the genuine Bob and not some imposter.
A few big names in the CA business are Verisign, Thawte, Entrust, and Valicert. Also, the
current industry standard for digital certificates is X.509 from CCITT (stands for Commite’
Consultatif International de Telecom- munications et Telegraphy in French).
XML Encryption
The XML Encryption standard is currently been developed at the W3C. W3C officially
undertook the XML Encryption activity in late January 2001. At present, XML Encryption
is a Candidate Recommendation—that is, it has yet to become a W3C standard. (A
specification becomes an official W3C standard once it attains the W3C recommendation
status.)
XML Encryption forms the basis of Web services security. This technol- ogy is aimed at
defining the process of encrypting and decrypting digital content. XML Encryption is so
called because it uses XML syntax for repre- senting the content that has been encrypted
as well as for representing the information that enables the recipient of the encrypted
content to decrypt it. XML Encryption does not talk about other security issues such as
authentication, authorization, integrity, or trust, although it may form the basis for them.
The standard is completely centered on providing confi- dentiality to the information that
has been encrypted.
$5,000 in return. In order to make the purchase, Bob supplies all the rele- vant
information to Sue Company. This information also consists of Bob’s American Bank
account number, which is obviously a sensitive piece of information. As a result, before
Bob puts this information on the wire, he needs to ensure that he has encrypted it. Now
based on what Bob wants to encrypt, he can either use SSL/TLS or XML Encryption. For
example, if Bob wants to encrypt the entire information, he can very well use SSL/TLS.
However, if he just wants to keep the account number confidential, then he would want to
use XML Encryption to encrypt just that particular piece of information. This use case
scenario is illustrated in Figure 13.4.
Once Sue Company had received the purchase order from Bob, it would need to debit the
amount for that particular sale from Bob’s American Bank account. As a result, Sue
Company would need to inform the American Bank to do so. Now, when Sue Company
passes this particular information to American Bank, it definitely needs to encrypt the
bank account number to keep it confidential from unintended recipients, such that only
the American Bank can decrypt it. However, Sue Company also may want to encrypt the
information about the specific purchase (that is, that Bob pur- chased 100 covers), such
that American Bank cannot decrypt it. The reason that the Sue Company might want to do
this is because of privacy con- cerns: American Bank does not need to know what specific
purchase Bob made. And that is where XML Encryption can play its role. Using XML
Encryption technology, the Sue Company can encrypt different pieces of data with
different keys so that the recipient can decrypt and thus read only the piece of data that it
is supposed to. This scenario is illustrated in Figure 13.5.
Bob purchased <EncryptedData> from us and
agrees to pay $5000 in turn using his American
Bank account <EncryptedData>
Sue Co. American
Bank