3. Web Services?
Any piece of s/w that makes itself
available over the internet and uses
XML messaging system.
Due to XML communication, WS is
OS or pgming language independent.
Eg:- Java can talk with Perl; Windows
app can talk with Unix app.
4. Web Services
Services available on web
Examples:
1. Social media web service:
communicate with your friends
2. E-commerce webservice :
online purchasing
5. Web Site vs Web Services
Web site human consumption
WS application consumption
6. Why Web Services?
App Server1 App Server2
m/c1 m/c2
X
(jar)
getProducts()
MVC
Client calls getProducts()
getProducts()
7. Why Web Services?
getProducts() in Appserver2 can’t
call getProducts() in AppServer1.
Solution:
Make the getProducts() as jar file
& put it in AppServer2.
8. Why Web Services?
Problems:
Db difference in AppServer2
Modifications in getProducts()
in AppServer1 can’t reflect in
AppServer2. (so repack another
jar for modified getProductsI())
9. Why Web Services?
App Server1 App Server2
m/c1 m/c2
direct call using
WS
getProducts()
MVC
Client calls getProducts()
getProducts()
10. Why Web Services?
+ve: interoperable
Language independent
java ws can invoke .Net WS
H/W independent
Ws running in Windows can call
Unix WS
11. Why Web Services?
+ve: interoperable
Eg:-
Google Maps In Chrome under
windows
Google Maps in IE under
Redhat Linux
13. Web services Building Blocks
SOAP (Simple Object Access Protocol)
XML based transport protocol
WSDL (Web Services Description Language)
XML based
To describe WS
UDDI(Universal Description, Discovery,
and Integration)
.NET based
To discover WS
14. SOAP (Simple Object Access Protocol)
SOAP = XML + HTTP
XML to encode & decode data
HTTP to transport data
Def:-
XML based communication protocol which is
language & platform independent.
15. Why SOAP?
DCOM & CORBA objects communicate
using RPC.
-ve of RPC:
Blocked by firewalls & proxy servers.
+ve of SOAP:-
No such blocking, moreover by using SOAP,
applications running on different OS, different
technologies, different PL can communicate
with each other.
16. SOAP Elements
1. Envelope Element (required)
2. Header Element (opt)
3.Body Element (required)
4.Fault Element (opt)
17. SOAP Elements
1. Envelope element identities the XML
as a SOAP message.
2. Header element contains WS std
info like authentication, pay load.
3. Body element contains the actual
information, call & response
information.
4. Fault element provides error
information occurred while
processing the msg.
20. SOAP HTTP Binding
After establishing a connection, the client
can send an HTTP request message to
the server:
POST /item HTTP/1.1
Host: 189.123.255.239
Content-Type: text/plain
Content-Length: 200
21. SOAP HTTP Binding
The server then processes the request
and sends an HTTP response back to the
client.
The response contains a status code that
indicates the status of the request:
200 OK status code
Content-Type: text/plain
Content-Length: 200
22. Why HTTP for SOAP?
HTTP is already a widely implemented, and well
understood, protocol.
SOAP messages are one-way, instead of two-way.
one from the "client" to the "server“ and one from the
"server" back to the "client”. But SOAP specification
also says that when a request/response protocol, such
as HTTP, is used, these two messages can be
combined in the request/response of the protocol.
Most firewalls are already configured to work with
HTTP.
HTTP makes it easy to build in security, with Secure
Sockets Layer (SSL)
24. WSDL (Web Services Description Language)
• WSDL is an XML document to describe
web services and how to access web
services
A client program connecting to a web
service can read the WSDL to determine
what functions are available on the
server.
The client can then use SOAP to actually
call one of the functions listed in the
WSDL.
27. Definition Element
root element of all WSDL documents
Associates WS with its namespaces.
Defines one or more WS.
contains all the service elements described
here.
• Types to define datatypes used by
WS using XSD.
• Message piece of information
exchanged between C/S.
28. WSDL (Web Services Description Language)
• Operation actions which are
supported by WS.
• PortType collection of operations
• Binding links abstract section with
actual section or concrete section.
• Port endpoint defined in terms of URL
• Service how to consume WS?
Collection of related end pts.
30. Definition Element
targetNamespace unique logical namespace
for WS.
xmlns default WSDL namespace which
contains <definition>, <message> …
xmlns:tns optional attribute contains same
value as targetNamespace.
Xmlns:soap & xmlns:xsd std namespace for
SOAP information and data types.
31. Types Element
To define datatypes used by WS using XSD.
<types>
<schema targetNamespace
="http://www.mysite.com/myservice.wsdl"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name=“MyRequest">
</element>
</schema>
</types>
User defined schema
Std schema
32. Message Element
Definition element contains one or more message
elements.
<message name="getMyInput">
<part name="term" type="xs:string"/>
</message>
<message name="getMyOutput">
<part name="value" type="xs:string"/>
</message>
Each msg element can contain any no of part
child elements.
2 message elements (1- request, 2-
response)
33. PortType Element
PortType element contains one or more operation
elements.
portType class or I/f
Operation method
<portType name=“MyServicePortType">
<operation name=“MyMethod">
<input message=“tns:getMyInput"/>
<output message=" tns:getMyOutput"/>
</operation>
</portType>
35. Service Element
• Web service clients can learn the following from
the service element:
– where to access the service,
– through which port to access the web service, and
– how the communication messages are defined.
• documentation element to provide human-
readable documentation.
36. Service Element
<service name=“MyService">
<documentation>WSDL File for MyService</documentation>
<port name=“MyServicePort” binding="tns:MyServiceBinding“>
<soap:address
location="http://www.mysite.com/MyService/">
</port>
</service>
Example pgm: combine all elements code
38. UDDI (Universal Description, Discovery, and Integration)
• UDDI is platform independent registry in
which business can publish their services &
also it provides mechanism to locate web
services
By OASIS (Advancing Open Standard for
Information Society)
UDDI provides publication & discovery of WS
which are key components of SOA.
39. UDDI Basics
Public UDDI registries are hosted by
companies such as IBM, Microsoft.
DNS Vs UDDI
DNS (nameIP address) is a static DB.
Where as UDDI provides information on how
to find & invoke WS.
GUID (Globally Unique Identifiers)
to uniquely identify the resources in each
registry.
40. 3 Levels of Information in UDDI
White Pages Companies general information
such as Name, Address, Contact Number.
Yellow Pages Looking up companies by their
kind of services.
Green Pages Provides information about how
to interact with companies web services.
41. UDDI Structure
UDDI provides 4 types of information.
1. Business Information
2. Service Information
3. Binding Information
4. Service Specification
42. UDDI Structure
Business Entity
Business Service
Business Service
Binding Template
Binding Template
Binding Template
Binding Template
tModel
tModel
tModel
tModel
43. UDDI Structure
1.Business Information (abt org,
Group of ppl who register their
services in registry)
Provided by BusinessEntity
Element.
Supports white pages & yellow
pages.
This element is top level
information manager.
44. UDDI Structure
2. Service Information (Resources
provided by business)
Provided by BusinessService
Element.
Supports green pages.
This element is top level
information manager.
45. UDDI Structure
3. Binding Information (info abt how to
bind & invoke WS)
Provided by BindingTemplate
Element.
BindingTemplate element is within
BindingService element.
46. UDDI Structure
4. Service Specification
Enclosed within each
BIndingTemplate Element.
tModel elements (Technical
Models)
tModel pointer to WDSL file.