0% found this document useful (0 votes)
34 views31 pages

Web Services & APIs Overview

Uploaded by

pakijabangles786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views31 pages

Web Services & APIs Overview

Uploaded by

pakijabangles786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Advanced PHP

SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

5.1 Definition of web services

What is an API?

Application Programming Interface(API) is a software interface that allows


two applications to interact with each other without any user intervention. API
is a collection of software functions and procedures. In simple terms, API
means a software code that can be accessed or executed. API is defined as a
code that helps two different software's to communicate and exchange data with
each other.

It offers products or services to communicate with other products and services


without having to know how they're implemented.

How does it work?

To understand the functionality of the API, let see the following example:

Example 1:

Let see how API works using simple daily life example. Imagine that you went
to a restaurant to take lunch or dinner. The waiter comes to you gives you a
menu card, and you will provide personalize it order like you want a veg
sandwich but without onion.

After some time, you will get your order from the waiter. However, it is not that
simple as it looks as there is some process that happens in between.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

Here, the waiter plays an important part as you will neither go to the kitchen to
collect your order nor will you tell the kitchen staff what you want all this done
by the waiter.

API also does the same by taking your request, and just like the waiter tell the
system what you want and give a response back to you.

Why would we need an API?

Here, are some reason for using API:

 Application Programming Interface acronym API helps two different


software's to communicate and exchange data with each other.
 It helps you to embed content from any site or application more
efficiently.
 APIs can access app components. The delivery of services and
information is more flexible.
 Content generated can be published automatically.
 It allows the user or a company to customize the content and services
which they use the most.
 Software needs to change over time, and APIs help to anticipate changes.

Features of API

Here are some important features of API:

 It offers a valuable service (data, function, audience,.).


 It helps you to plan a business model.
 Simple, flexible, quickly adopted.
 Managed and measured.
 Offers great developer support.

Types of API

There are mainly four main types of APIs:

 Open APIs: These types of APIs are publicly available to use like OAuth
APIs from Google. It has also not given any restriction to use them. So,
they are also known as Public APIs.
 Partner APIs: Specific rights or licenses to access this type of API
because they are not available to the public.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

 Internal APIs: Internal or private. These APIs are developed by


companies to use in their internal systems. It helps you to enhance the
productivity of your teams.

Communication level of APIs:

Here, are some communication level of APIS:

High-Level APIs:

High-level APIs are those that we can generally use in REST form, where
programmers have a high level of abstraction. These API's mostly concerned
about performing a limited functionality.

Low-Level APIs:

This kind of APIs has a lower level of abstraction, which means they are more
detailed. It allows the programmer to manipulate functions within an application
module or hardware at a granular level.

What is Web APIs?

A Web API is an application programming interface which is use either for web
server or a web browser.

Two types of Web APIs are 1) Server-side 2) Client-side

1.Server-side:

Server-side web API is a programmatic interface that consist of one or more


publicly exposed endpoints to a defined request–response message system. It is
typically expressed in JSON or XML

2.Client-side:

A client-side web API is a programmatic interface helps to extend functionality


within a web browser or other HTTP client.

Examples of web API:

 Google Maps API's allow developers to embed Google Maps on


webpages by using a JavaScript or Flash interface.
 YouTube API allows developers to integrate YouTube videos and
functionality into websites or applications.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

 Twitter offers two APIs. The REST API helps developers to access
Twitter data, and the search API provides methods for developers to
interact with Twitter Search.
 Amazon's API gives developers access to Amazon's product selection.

What is Web Service?


Web service is a standardized medium to propagate communication between
the client and server applications on the World Wide Web. A web service is a
software module that is designed to perform a certain set of tasks.

 Web services in cloud computing can be searched for over the network
and can also be invoked accordingly.
 When invoked, the web service would be able to provide the functionality
to the client, which invokes that web service.

How Web Services Work?

Ho
w Web Services Work?
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

The above diagram shows a very simplistic view of how a web service
would actually work. The client would invoke a series of web service
calls via requests to a server which would host the actual web service.

These requests are made through what is known as remote procedure


calls. Remote Procedure Calls(RPC) are calls made to methods which are
hosted by the relevant web service.

As an example, Amazon provides a web service that provides prices for


products sold online via amazon.com. The front end or presentation layer
can be in .Net or Java but either programming language would have the
ability to communicate with the web service.

The main component of a web service design is the data which is


transferred between the client and the server, and that is XML. XML
(Extensible markup language) is a counterpart to HTML and easy to
understand the intermediate language that is understood by many
programming languages.

So when applications talk to each other, they actually talk in XML. This
provides a common platform for application developed in various
programming languages to talk to each other.

Web services use something known as SOAP (Simple Object Access


Protocol) for sending the XML data between applications. The data is
sent over normal HTTP. The data which is sent from the web service to
the application is called a SOAP message. The SOAP message is nothing
but an XML document. Since the document is written in XML, the client
application calling the web service can be written in any programming
language.

Why do you need a Web Service?

Modern day business applications use variety of programming platforms


to develop web-based applications. Some applications may be developed
in Java, others in .Net, while some other in Angular JS, Node.js, etc.

Most often than not, these heterogeneous applications need some sort of
communication to happen between them. Since they are built using
different development languages, it becomes really difficult to ensure
accurate communication between applications.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

Here is where web services come in. Web services provide a common
platform that allows multiple applications built on various programming
languages to have the ability to communicate with each other.

Type of Web Service

There are mainly two types of web services.

1. SOAP web services.


2. RESTful web services.

In order for a web service to be fully functional, there are certain


components that need to be in place. These components need to be
present irrespective of whatever development language is used for
programming the web service.

5.2 Basic operational model of web services, tools and technologies enabling
web services
SOAP (Simple Object Access Protocol)

SOAP is known as a transport-independent messaging protocol. SOAP is


based on transferring XML data as SOAP Messages. Each message has
something which is known as an XML document. Only the structure of
the XML document follows a specific pattern, but not the content. The
best part of Web services and SOAP is that its all sent via HTTP, which
is the standard web protocol.

Here is what a SOAP message consists of

3. Each SOAP document needs to have a root element known as the


<Envelope> element. The root element is the first element in an
XML document.
4. The "envelope" is in turn divided into 2 parts. The first is the
header, and the next is the body.
5. The header contains the routing data which is basically the
information which tells the XML document to which client it needs
to be sent to.
6. The body will contain the actual message.

The diagram below shows a simple example of the communication via


SOAP.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

SO
AP Protocol

RESTful Web Services

REST stands for REpresentational State Transfer. It is developed by Roy


Thomas Fielding who also developed HTTP. The main goal of RESTful web
services is to make web services more effective. RESTful web services try to
define services using the different concepts that are already present in HTTP.
REST is an architectural approach, not a protocol.

It does not define the standard message exchange format. We can build REST
services with both XML and JSON. JSON is more popular format with REST.
The key abstraction is a resource in REST. A resource can be anything. It can
be accessed through a Uniform Resource Identifier (URI). For example:

The resource has representations like XML, HTML, and JSON. The current
state is captured by representational resource. When we request a resource, we
provide the representation of the resource. The important methods of HTTP are:

o GET: It reads a resource.


o PUT: It updates an existing resource.
o POST: It creates a new resource.
o DELETE: It deletes the resource.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

For example, if we want to perform the following actions in the social media
application, we get the corresponding results.

POST /users: It creates a user.

GET /users/{id}: It retrieve the detail of one user.

GET /users: It retrieve the detail of all users.

DELETE /users: It delete all users.

DELETE /users/{id}: It delete a user.

GET /users/{id}/posts/post_id: It retrieve the detail of a specific post.

POST / users/{id}/ posts: It creates a post for a user.

GET /users/{id}/post: Retrieve all posts for a user

HTTP also defines the following standard status code:

o 404: RESOURCE NOT FOUND


o 200: SUCCESS
o 201: CREATED
o 401: UNAUTHORIZED
o 500: SERVER ERROR

RESTful Service Constraints


o There must be a service producer and service consumer.
o The service is stateless.
o The service result must be cacheable.
o The interface is uniform and exposing resources.
o The service should assume a layered architecture.

Advantages of RESTful web services


o RESTful web services are platform-independent.
o It can be written in any programming language and can be executed on
any platform.
o It provides different data format like JSON, text, HTML, and XML.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

o It is fast in comparison to SOAP because there is no strict specification


like SOAP.
o These are reusable.
o These are language neutral.

WSDL (Web services description language)


A web service cannot be used if it cannot be found. The client
invoking the web service should know where the web service actually
resides.

Secondly, the client application needs to know what the web service
actually does, so that it can invoke the right web service. This is done
with the help of the WSDL, known as the Web services description
language. The WSDL file is again an XML-based file which basically
tells the client application what the web service does. By using the
WSDL document, the client application would be able to understand
where the web service is located and how it can be utilized.

Universal Description, Discovery, and Integration (UDDI)

UDDI is a standard for describing, publishing, and discovering the web


services that are provided by a particular service provider. It provides a
specification which helps in hosting the information on web services.

Now we discussed in the previous topic about WSDL and how it contains
information on what the Web service actually does. But how can a client
application locate a WSDL file to understand the various operations
offered by a web service? So UDDI is the answer to this and provides a
repository on which WSDL files can be hosted. So the client application
will have complete access to the UDDI, which acts as a database
containing all the WSDL files.

Just as a telephone directory has the name, address and telephone


number of a particular person, the same way the UDDI registry will
have the relevant information for the web service. So that a client
application knows, where it can be found.

5.3 Benefits and challenges of using web services.


Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

Web Services Advantages

We already understand why web services came about in the first place,
which was to provide a platform which could allow different applications
to talk to each other.

But let's look at the list of web services advantages for why it is important
to use web services.

1. Exposing Business Functionality on the network - A web service


is a unit of managed code that provides some sort of functionality
to client applications or end users. This functionality can be
invoked over the HTTP protocol which means that it can also be
invoked over the internet. Nowadays all applications are on the
internet which makes the purpose of Web services more useful.
That means the web service can be anywhere on the internet and
provide the necessary functionality as required.
2. Interoperability amongst applications - Web services allow
various applications to talk to each other and share data and
services among themselves. All types of applications can talk to
each other. So instead of writing specific code which can only be
understood by specific applications, you can now write generic
code that can be understood by all applications
3. A Standardized Protocol which everybody understands - Web
services use standardized industry protocol for the communication.
All the four layers (Service Transport, XML Messaging, Service
Description, and Service Discovery layers) uses well-defined
protocols in the web services protocol stack.
4. Reduction in cost of communication - Web services use SOAP
over HTTP protocol, so you can use your existing low-cost internet
for implementing web services.

5.4 Web services Architecture and its characteristics

Web Services Architecture

Every framework needs some sort of architecture to make sure the entire
framework works as desired, similarly, in web services. The Web
Services Architecture consists of three distinct roles as given below:

Provider - The provider creates the web service and makes it


available to client application who want to use it.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

Requestor - A requestor is nothing but the client application that


needs to contact a web service. The client application can be a .Net,
Java, or any other language based application which looks for some
sort of functionality via a web service.

Broker - The broker is nothing but the application which provides


access to the UDDI. The UDDI, as discussed in the earlier topic
enables the client application to locate the web service.

The diagram below showcases how the Service provider, the Service
requestor and Service registry interact with each other.

Web Services Architecture


Publish - A provider informs the broker (service registry) about the
existence of the web service by using the broker's publish interface to
make the service accessible to clients

Find - The requestor consults the broker to locate a published web


service

Bind - With the information it gained from the broker(service registry)


about the web service, the requestor is able to bind, or invoke, the web service.

Web service Characteristics


Web services have the following special behavioural characteristics:

5. They are XML-Based - Web Services uses XML to represent the


data at the representation and data transportation layers. Using
XML eliminates any networking, operating system, or platform
sort of dependency since XML is the common language understood
by all.
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

6. Loosely Coupled – Loosely coupled means that the client and the
web service are not bound to each other, which means that even if
the web service changes over time, it should not change the way
the client calls the web service. Adopting a loosely coupled
architecture tends to make software systems more manageable and
allows simpler integration between different systems.
7. Synchronous or Asynchronous functionality- Synchronicity
refers to the binding of the client to the execution of the service. In
synchronous operations, the client will actually wait for the web
service to complete an operation. An example of this is probably a
scenario wherein a database read and write operation are being
performed. If data is read from one database and subsequently
written to another, then the operations have to be done in a
sequential manner. Asynchronous operations allow a client to
invoke a service and then execute other functions in parallel. This
is one of the common and probably the most preferred techniques
for ensuring that other services are not stopped when a particular
operation is being carried out.
8. Ability to support Remote Procedure Calls (RPCs) - Web
services enable clients to invoke procedures, functions, and
methods on remote objects using an XML-based protocol. Remote
procedures expose input and output parameters that a web service
must support.
9. Supports Document Exchange - One of the key benefits of XML
is its generic way of representing not only data but also complex
documents. These documents can be as simple as representing a
current address, or they can be as complex as representing an entire
book.

5.5 Core building blocks of web services:


 XML
 SOAP
 WSDL
 UDDI

5.6 Standards and technologies available for implementing web services

Standards

Transports
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

BEEP, the Blocks Extensible Exchange Protocol (formerly referred to as


BXXP), is a framework for building application protocols. It has been
standardized by IETF and it does for Internet protocols what XML has done for
data.
 Blocks Extensible Exchange Protocol (BEEP)
Messaging
These messaging standards and specifications are intended to give a framework
for exchanging information in a decentralized, distributed environment.
 SOAP 1.1 (Note)
 SOAP 1.2 (Specification)
 Web Services Attachments Profile 1.0
 SOAP Message Transmission Optimization Mechanism

Description and Discovery

Web services are meaningful only if potential users may find information
sufficient to permit their execution. The focus of these specifications and
standards is the definition of a set of services supporting the description and
discovery of businesses, organizations, and other web services providers; the
web services they make available; and the technical interfaces which may be
used to access those services.
 UDDI 3.0
 WSDL 1.1 (Note)
 WSDL 1.2 (Working draft)
 WSDL 2.0 (Working Group)

Security

Using these security specifications, applications can engage in secure


communication designed to work with the general web services framework.
 Web Services Security 1.0
 Security Assertion Markup Language (SAML)

Management

Web services manageability is defined as a set of capabilities for discovering


the existence, availability, health, performance, usage, as well as the control
and configuration of a web service within the web services architecture. As
web services become pervasive and critical to business operations, the task of
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

managing and implementing them is imperative to the success of business


operations.
 Web Services Distributed Management

Technologies used in Web Services:-

Web Services Technologies Overview


• XML Technologies – “Extensible Markup Language” – Base XML for
documents – XML Schema for describing XML documents
• SOAP – “Simple Object Access Protocol” • A simple way to send documents
(some people have called it “email for documents”) – How to format XML
documents for transmission
• WSDL – “Web Services Description Language” – Defines all details about a
service
• UDDI – “Universal Description, Discovery and Integration” – One way to
advertise and discover services
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

XML Technologies

• Collection of extensible information representation


and manipulation technologies

– XML itself – the base document standard


– XML Schema – for data typing and
document structuring
– XSLT – for transforming XML to other XML or
other formats
– Parsing strategies for XML document processing
• DOM – Document Object Model
• SAX – Simple API for XML
– Others: XPATH, XQUERY, etc.

XML – eXtensible Markup Language

• Originally a derivative of SGML in the family of markup


languages
• Similar to HTML in appearance, but with a very different
goal
 to separate data content from data presentation
• Now, a full and evolving W3C standard
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

• Parsable, extensible and self-describing text format for


exchanging information
– Platform-, hardware-, programming-language-neutral
– Highly portable across heterogeneous networks

Important characteristics of XML


• Similar in appearance to HTML
– HTML has a fixed set of tags, XML has a variable set
• Two major structuring mechanisms:
– Elements that may contain text and/or other elements
– Attributes characterize elements with simple strings
• Elements are demarcated by Tags at the start and end:
• E.g., a MyElement element
<MyElement> …. </MyElement>
• Nested elements are used to model complex data
• We’ll see many examples of this
• Extensible – can define new elements and attributes easily

Parsing XML documents

• Processing XML documents within programs typically


requires XML parsing capabilities
• Two most popular parsing approaches:
– DOM – Document Object Model
• Read and represent entire document in memory
as a tree of nodes allowing for easy traversal
throughout the document
• You can modify the tree, and make a call to
DOM to tell it to output the new tree as a
document
– SAX – Simple API for XML
• Event driven parsing model that invokes
callbacks for major XML elements as they are
read from the document
• Can be more efficient than DOM for large document
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

processing
• Used more for extracting sub-document
information and specific processing

XML Namespaces provide a method to avoid element name conflicts.

Name Conflicts

• In XML, element names are defined by the developer. This often


results in a conflict when trying to mix XML documents from
different XML applications.
• This XML carries HTML table information:

• <table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>

• This XML carries information about a table (a piece of furniture):

• <table>
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>

• If these XML fragments were added together, there would be a name


conflict. Both contain a <table> element, but the elements have
different content and meaning.
• A user or an XML application will not know how to handle these
differences.

• Solving the Name Conflict Using a Prefix

• Name conflicts in XML can easily be avoided using a name prefix.


Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

• This XML carries information about an HTML table, and a piece of


furniture:

• <h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>

<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>

• In the example above, there will be no conflict because the two


<table> elements have different names.

What is a DTD?

DTD stands for Document Type Definition.

A DTD defines the structure and the legal elements and attributes of an XML
document.

Valid XML Documents

A "Valid" XML document is "Well Formed", as well as it conforms to the rules


of a DTD:

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

The DOCTYPE declaration above contains a reference to a DTD file. The


content of the DTD file is shown and explained below.

XML DTD

The purpose of a DTD is to define the structure and the legal elements and
attributes of an XML document:

Note.dtd:
<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>

The DTD above is interpreted like this:

 !DOCTYPE note - Defines that the root element of the document is note
 !ELEMENT note - Defines that the note element must contain the
elements: "to, from, heading, body"
 !ELEMENT to - Defines the to element to be of type "#PCDATA"
 !ELEMENT from - Defines the from element to be of type "#PCDATA"
 !ELEMENT heading - Defines the heading element to be of type
"#PCDATA"
 !ELEMENT body - Defines the body element to be of type "#PCDATA"

NOTE :#PCDATA means parseable character data.

Using DTD for Entity Declaration

A DOCTYPE declaration can also be used to define special characters or


strings, used in the document:

Example
<?xml version="1.0" encoding="UTF-8"?>
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

<!DOCTYPE note [
<!ENTITY nbsp "&#xA0;">
<!ENTITY writer "Writer: Donald Duck.">
<!ENTITY copyright "Copyright: W3Schools.">
]>

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<footer>&writer;&nbsp;&copyright;</footer>
</note>
XML Schema

XML Schema is an XML-based alternative to DTD:

<xs:element name="note">

<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>

</xs:element>

The Schema above is interpreted like this:

 <xs:element name="note"> defines the element called "note"


 <xs:complexType> the "note" element is a complex type
 <xs:sequence> the complex type is a sequence of elements
 <xs:element name="to" type="xs:string"> the element "to" is of type
string (text)
 <xs:element name="from" type="xs:string"> the element "from" is of
type string
 <xs:element name="heading" type="xs:string"> the element "heading" is
of type string
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

 <xs:element name="body" type="xs:string"> the element "body" is of


type string

XML Schemas are More Powerful than DTD

 XML Schemas are written in XML


 XML Schemas are extensible to additions
 XML Schemas support data types
 XML Schemas support namespaces

XSLT:

XSL (eXtensible Stylesheet Language) is a styling language for XML.

XSLT stands for XSL Transformations.

XSLT is a language for transforming XML documents.

XPath is a language for navigating in XML documents.

XQuery is a language for querying XML documents.

It Started with XSL

XSL stands for EXtensible Stylesheet Language.

The World Wide Web Consortium (W3C) started to develop XSL because there
was a need for an XML-based Stylesheet Language.

CSS = Style Sheets for HTML

HTML uses predefined tags. The meaning of, and how to display each tag is
well understood.

CSS is used to add styles to HTML elements.


Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

XSL = Style Sheets for XML

XML does not use predefined tags, and therefore the meaning of each tag is not
well understood.

A <table> element could indicate an HTML table, a piece of furniture, or


something else - and browsers do not know how to display it!

So, XSL describes how the XML elements should be displayed.

XSL - More Than a Style Sheet Language

XSL consists of four parts:

 XSLT - a language for transforming XML documents


 XPath - a language for navigating in XML documents
 XSL-FO - a language for formatting XML documents (discontinued in
2013)
 XQuery - a language for querying XML documents

What is XSLT?

 XSLT stands for XSL Transformations


 XSLT is the most important part of XSL
 XSLT transforms an XML document into another XML document
 XSLT uses XPath to navigate in XML documents
 XSLT is a W3C Recommendation

Correct Style Sheet Declaration

The root element that declares the document to be an XSL style sheet is
<xsl:stylesheet> or <xsl:transform>.

Note: <xsl:stylesheet> and <xsl:transform> are completely synonymous and


either can be used!

The correct way to declare an XSL style sheet according to the W3C XSLT
Recommendation is:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

or:

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

To get access to the XSLT elements, attributes and features we must declare the
XSLT namespace at the top of the document.

The xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official


W3C XSLT namespace. If you use this namespace, you must also include the
attribute version="1.0".

Other XML Specifications


• XPATH
– XML-based syntax to provide sophisticated access to parts of an
XML document – used heavily with XSLT for transforming XML
• XQUERY
– An SQL-like dialect for querying parts of varying XML data
sources
– Extension to XPATH
• XML-Encryption – (to be seen later in more detail)
– Process for encrypting/decrypting parts of XML docs
• XML-Signature – (to be seen later in more detail)
– To ensure origin and integrity of XML docs
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

5.7 Web services communication models

RPC-Based Communication Model


The RPC-based communication model defines a request/response-based
synchronous communication. When the client sends a request, the client waits
Advanced PHP
SYBBA (CA)
Chapter V– Introduction of Web Services Ms. Pooja R .Kamble

until a response is sent back from the server before continuing any operation.
Typical to implementing CORBA or RMI communication, the RPC-based Web
services are tightly coupled and are implemented with remote objects to the
client application.

Messaging-Based Communication Model


The messaging-based communication model defines a loosely coupled and
document-driven communication. The service requestor invoking a messaging-
based service provider does not wait for a response.

5.8 Basic steps of implementing web services.

Implementing a simple Web Service

We'll follow these steps to create our simple Web Service:

 Create the Web Service business logic. First we need to write a Java class
that implements the Web Service business logic. In this case, our business
logic will be a simple Java class that simulates a stock quote service.

 Deploy the Java class to the SOAP server. Next we need to turn the Java
class into a Web Service. We'll show how to deploy the Java class to a
SOAP server using the WASP deployment tool.

 Generate client access classes. A client application uses a proxy object to


access a Web Service. At request time, the proxy accepts a Java method call
from the application and translates it into an XML message. At response
time, the proxy receives the SOAP reply message, translates it into Java
objects, and returns the results to the client application.

 Client application development. The client application treats the proxy as a


standard Java object that facilitates the communication with a Web Service.

You might also like