Introduction to Web Services and the cocnept

PaceInfotech 5 views 38 slides Jun 14, 2024
Slide 1
Slide 1 of 38
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38

About This Presentation

Web Services

Basics and details of the concepts


Slide Content

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

What are Web Services?
•Middleware for distributed applications
•For remote procedure calls and data
exchange
•Open standard based on XML
•For loosely coupled software services
•Independent of programming languages
and operating systems
•Utilizing existing Internet protocols and
server architectures

Definition Web Service (by W3C)
•Software application identified by URL
•interface description in XML
•interaction on the basis of XML encoded
messages
•message exchange on the basis of
Internet protocols

Independence and Integration
through ...
•SOAP
–XML standard for message encoding
–independent of transport protocol
–independent of client and server implementations: Java, .NET,
Python, …
•Web Services Description Language -WSDL (1.1)
–Interface description in XML
•Communication on the basis of existing protocols and
server architectures
–HTTP and Web server
–SMTP and mail server
–FTP and FTP server
•Standardisation (W3C)
–SOAP 1.2, WSDL 1.1 (1.2 und 2.0)
–additional protocols based on SOAP and WSDL
–protocol bindings (HTTP)

Web Services ScenarioIIS (.NET web service container)
Web
Service A
Web
Service B
web server + Java
web service
container
Web-
Service C
SOAP
HTTP
e-mail server +
SOAP processor
Web
Service
D
.NET client
Java client
script client
SOAP
SMTP
SOAP
protocol
remote
procedure call
... client
SOAP
HTTP
SOAP
HTTP
SOAP
HTTP
SOAP
protocol X
SOAP
SMTP

Pros and Cons
•Pros
–independent of programming language, run
time environment and operating system
–Built on existing Internet infrastructure
–standardized
–promoted from important players (Microsoft,
IBM, SAP, Sun)
•Cons
–performance (XML)

Web Service Infrastructureclient(s)
E.g.: UDDI,
DISCO
Discover Services
What services do exist?
Where are they? (URL)
Service Description (in WSDL)
What message does the service
know and how are those called?
Service Calls
Using services via
SOAP, HTTP, XML-RPC, ...
Web Service
+ container

Universal, Description, Discovery
and Integration (UDDI)
•Standardized protocol for searching for and using web
services
•Provides web services interface
Directory
(UDDI)
1.) register
2.) search
3.) connect
4.) call
Client
Web
Service A
Web
Service B
URL: http://www.uddi.org

Web Service Architecture (1) Client
Web service
container
Web
Service
Discovery service
WSD1 URL1
WSD2 URL2
... ...
call
search
publish
inquiry

Web Service Architecture (2)Client
Web service
container
Discovery service
WSD1 URI1
WSD2 URI2
... ...
search
publish
Web
service service inquiry (URI)
service description (WSD) service inquiry
service description (WSD) service call
result service call (SOAP)
result: SOAP

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

Web Services in .NET
•IIS and ASP.NET infrastructure support web services
•.NET Framework provides several
–base classes
–attributes
–protocols
for the realization of web services
•Visual Studio.NET provides powerful tools for
developing web services
–implementation
–testing
–administration of IIS
–generation of proxy code (wsdl.exe)

.NET Namespaces
•System.Web.Services
–for developing web services (e.g.:
WebService, WebMethod)
•System.Web.Services.Configuration
–for extending SOAP
•System.Web.Services.Description
–for creating and manipulating WSDL
descriptions
•System.Web.Services.Protocols
–for implementation of communication
protocols (e.g. SOAP-HTTP)
•System.Xml.Serialization
–for XML serialization

Implementation of Web Services
public classMyWebService: WebService{
deriving a class from base class System.Web.Services.WebService
[WebMethod(Description= “comment ")]
[…]
public Returntype MyWebMethod( …) {

Identification and settings by .NET attributes
identification of web service methods
definition of format and encoding
XML namespaces and element names to use
etc.

Building a Web Service
Open File -> New -> select ASP.NET
Web Services
Define a class that inherits from
System.Web.Services.WebService
VS .NET creates a skeleton webservice
Using System.Web;
Using System.Web.Services;
Using System.Web.Services.Protocols;
Public class Service : System.Web.Services.WebService {
[WebMethod]
Public string Helloworld()
{
return “Hello World”;
} }

Web Service Program –Example1

Viewing Web Service page

Testing Add ( ) Web Service
Method

Result of Add() Method (in XML)

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

SOAP
•Simple message protocol in XML
–for packaging arbitrary application data
–single messages only („one-way“)
–asynchronous
•Independent of transport protocol
•SOAP does notdefine:
–distributed object model
–communication protocol
–distributed garbage collection
–distributed events (distributed callbacks)

Application of SOAP
•SOAP is extendable
–method call protocol (RPC)
–security
–authentication
–etc.
•Protocol realisation by combination of messages
(message exchange patterns)
–one-way, request-response, multicast, …
1: GetTime_Request
2: GetTime_ResponseClient Server
e.g.: request-response for RPC by 2 messages

SOAP Messages <Envelope>
<Header>
<Body>
Data
Message Header
Message Header
<Fault>
Fault Descriptions
•envelope (<Envelope>)
as container
•letter head (<Header>)
with meta information
(Message Headers)
•letter (<Body>)
with arbitrary XML data
•fault descriptions
(<Fault>)
SOAP messages comparable to letters with

A SOAP Message
SOAP Message
SOAP Envelope
SOAP Header
SOAP Body
Message Name & Data
Headers
Protocol Headers
Standard Protocol (HTTP, SMTP, etc.)
and SOAP Headers
The complete SOAP Message
<Envelope> encloses payload
Individual headers
<Body> contains SOAP
Message Name and Data
XML Encoded SOAP
Message Name and Data

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

Web Service Description Language (WSDL)
•WSDL is an XML based IDL for web services
•a WSD describes:
–used data types
–structure of messages
–operations (methods)
–protocols to call operations
–addresses of web service
current version in .NET: WSDL 1.1
(http://schemas.xmlsoap.org/wsdl/)

concrete
part
abstract
part
Structure of WSDL 1.1
<definitions>
<types>
</types>
<message>
<part>
</part>
</message>
<portType>
<operation>
<input>
<output>
</operation>
</portType>
<binding>
<operation>
</binding>
<service>
<port>
</service>
</definitions>
WSDL description of a web services
types defined in <xsd:schema>
simple messages
parts of messages
interface specification
operations of an interface
input message
output message
binding of interface to protocols and encoding
description of the binding for each operation
service description
URI and binding to port

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/
xmlns:tns="http://dotnet.jku.at/time/"
xmlns:s="http://www.w3.org/2001/XMLSchema“
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/“
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/“
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/“
targetNamespace="http://dotnet.jku.at/time/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
</types>
<messagename="GetTimeSoapIn" />
<messagename="GetTimeSoapOut">
<partname="GetTimeResult" type="s:string" />
</message>
<portTypename="TimeServiceSoap">
<operationname="GetTime">
<inputmessage="tns:GetTimeSoapIn" />
<outputmessage="tns:GetTimeSoapOut" />
</operation>
</portType>

WSDL for TimeService (1)
•WSDL description created by web container
(IIS)
http://localhost/WebProject1/TimeService.asmx?WSDL
abstract
part


<bindingname="TimeServiceSoap" type="tns:TimeServiceSoap">
<soap:bindingtransport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<operationname="GetTime">
<soap:operation soapAction="http://dotnet.jku.at/time/GetTime" style="rpc" />
<input>
<soap:body use="encoded" namespace="http://dotnet.jku.at/time/“
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="http://dotnet.jku.at/time/“
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<servicename="TimeService">
<documentation>Simple web service for querying the time</documentation>
<portname="TimeServiceSoap" binding="tns:TimeServiceSoap">
<soap:addresslocation="http://localhost/time/TimeService.asmx" />
</port>
</service>
</definitions>
WSDL for TimeService (2)
concrete
part

Creating Proxy
Proxy
•To represent the server on the client
•To bundle client requests into SOAP messages that are
sent to server
•To retrieve the responses
•Creating Proxy
•Enter wsdl @ VS Command-line prompt, followed by
path to WSDL
•Creates a C# proxy file with complex code produced by
WSDL tool to build the proxy DLL (needed to build your
client)
wsdl http://localhost/WebProject1/TimeService.asmx?wsdl

Proxy –Code
•Declare a class that derives from
SoapHttpClientProtocol class
•Constructor sets the URL Property to the
URL of .asmx page
•Provides Asynchronous support for your
methods.
Ex: Public class service1 :
System.Web.Services.Protocols.SoapHttpClientProtocol
Ex: Public Service1 ( ) { this.Url =
“http://localhost:19975/WebServiceExample/Service.asmx”;}
Creates Proxy file named Service1.cs
Ex: for Add ( ) method, it also creates BeginAdd ( ), EndAdd ( ), …

Testing the Web Service
•Create simple C# application. Right-click project
& add Service1.cs
•Example

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

Indigo
•Web services in .NET 2.0 are integrated in
Indigo
•Indigo unites
–.NET remoting
–Web services
–.NET Enterprise Services
in one uniform programming model
•Indigo provides
–reliable communication
–secure communication and authentication
–host independence
–message-based server activation

Indigo Architecture service
typed channel
untyped channel
port
formatter
transport
to destination
message flow

Web Services
Introduction
Web Services in .NET
SOAP
Service Description with WSDL
Preview of Web Services .NET 2.0
Summary

Summary
•Web services are a middleware technology
•on the basis of XML and Internet protocols
•independent of programming language and run
time system
•for the integration of heterogeneous, distributed
systems
•.NET supports web services
–development of web services
–development of web service clients
•In .NET 2.0 Indigo unites the different remoting
technologies