Introduction to Web Services by Denis Voituron

 
Introduction to
Web Services
 
Ir Denis VOITURON
http://www.dvoituron.be
 
Version 3.1
 
Goals
 
Understand the importance of Web Services
 
Basic notions of Web Services
 
Being able to create and debug a Web Service
Using the .NET Framework
Using Visual Studio.
 
Introduction to Web Services
 
2.-
 
Agenda
 
Overview of Web Services
 
Technologies used
 
How to create a Web Services
 
How to use a Web Services
 
Conclusion
 
Introduction to Web Services
 
3.-
 
The business today
 
Companies
Sharing business
processes
 
Working together
Quickly
With internet
Including
heterogeneous system
 
Introduction to Web Services
 
4.-
 
Solutions
 
Distributed applications
 
Internet Web Sites (portals)
 
Web Services
 
oData, Json
 
Introduction to Web Services
 
5.-
 
Distributed applications
 
Client / Server Model
Not extensible
Not secure
 
Based on distributed object model
Examples
COM, 
CORBA
, 
Java 
RMI
Not internet based
Not 
interoperable
No standards
 
Introduction to Web Services
 
6.-
 
Portals
 
Introduction to Web Services
 
7.-
 
M
a
i
l
 
C
a
l
e
n
d
a
r
 
N
e
w
s
 
F
i
n
a
n
c
e
 
W
e
a
t
h
e
r
 
O
t
h
e
r
S
v
c
s
 
A
d
s
 
Web Services
 
A programmable application component that is
accessible via standard Internet protocols
 
Web Methods
 
HTTP
 
Communicate using open protocols
 
W3C
 
Self-contained and self-describing
 
XML
 
Usable by other applications
 
Heterogeneous
 
Introduction to Web Services
 
8
 
Architecture
 
Introduction to Web Services
 
9
 
Source: Wikipedia
 
Example
 
How to convert Number to Roman
http://www.ebob42.com/cgi-bin/Romulan.exe/wsdl/Iroman
 
What is the 
weather for a given city
http://www.deeptraining.com/webservices/weather.asmx?wsdl
 
Using Google, Bing, Yahoo, …
 
Introduction to Web Services
 
10
 
Agenda
 
Overview of Web Services
 
Technologies used
 
How to create a Web Services
 
How to use a Web Services
 
Conclusion
 
Introduction to Web Services
 
11.-
 
XML
 
Introduction to Web Services
 
12.-
 
P
r
o
g
r
a
m
t
h
e
 
W
e
b
 
X
M
L
 
B
r
o
w
s
e
t
h
e
 
W
e
b
 
H
T
M
L
 
T
C
P
/
I
P
 
C
o
n
n
e
c
t
 
t
h
e
 
W
e
b
 
T
e
c
h
n
o
l
o
g
y
 
I
n
n
o
v
a
t
i
o
n
 
C
o
n
n
e
c
t
i
v
i
t
y
 
P
r
e
s
e
n
t
a
t
i
o
n
 
C
o
n
n
e
c
t
i
n
g
A
p
p
l
i
c
a
t
i
o
n
s
 
F
T
P
,
 
E
-
m
a
i
l
,
 
G
o
p
h
e
r
 
W
e
b
 
P
a
g
e
s
 
W
e
b
 
S
e
r
v
i
c
e
s
 
Protocols used
 
Introduction to Web Services
 
13
 
S
i
m
p
l
e
,
 
O
p
e
n
,
 
B
r
o
a
d
 
I
n
d
u
s
t
r
y
 
S
u
p
p
o
r
t
Architecture
Introduction to Web Services
14
f(x)
Service Broker
Service Requester
Service Provider
W
S
D
L
W
S
D
L
S
O
A
P
U
D
D
I
Source: Wikipedia
1
2
3
4
XML - eXtended Markup Language
Set of rules for encoding documents in human
readable form
XML Declaration
Unicode character
Tag or Element
Attribute
Introduction to Web Services
15.-
<?
xml
 
version
=
"
1.0
"
 
encoding
=
"
utf-8
"
 ?>
<
note
 
sendBy
=
"
Mail
"
>
  <
to
>
Tove
</
to
>
  <
from
>
Jani
</
from
>
  <
heading
>
Reminder
</
heading
>
  <
body
>
    Don't forget me this weekend!
  </
body
>
</
note
>
 
WSDL
 
Web Services Description Language
 
Describing the functionality offered by a Web
service
How the service can be called
What parameters it expects
What data structures it returns
 
Introduction to Web Services
 
16.-
 
WSDL
 
Description of 
GetWeather(string city)
 
Introduction to Web Services
 
17.-
    ...
<
soap:element
 
name
=
"
GetWeather
"
>
  <
soap:complexType
>
    <
soap:sequence
>
      <
soap:element
 
minOccurs
=
"
0
"
 
maxOccurs
=
"
1
"
                    
name
=
"
City
"
 
type
=
"
soap:string
"
/>
    </
soap:sequence
>
  </
soap:complexType
>
</
soap:element
>
<
soap:element
 
name
=
"
GetWeatherResponse
"
>
  <
soap:complexType
>
    <
soap:sequence
>
      <
soap:element
 
minOccurs
=
"
0
"
 
maxOccurs
=
"
1
"
                    
name
=
"
GetWeatherResult
"
 
type
=
"
soap:string
"
/>
    </
soap:sequence
>
  </
soap:complexType
>
</
soap:element
>
    ...
 
http://www.deeptraining.com/webservices/weather.asmx?wsdl
 
SOAP request and SOAP result
 
Call Web Method: 
GetWeather(string city)
 
Introduction to Web Services
 
18.-
<
soap:Envelope
 
xmlns:s
=
"
http://schemas.xmlsoap.org/soap/envelope/
"
>
  <
soap:Body
>
    <
GetWeather
>
        <
City
>
Brussels
</
City
>
    </
GetWeather
>
  </
soap:Body
>
</
soap:Envelope
>
<
soap:Envelope
 
xmlns:soap
=
"
http://schemas.xmlsoap.org/soap/envelope/
"
  <
soap:Body
>
    <
GetWeatherResponse
>
       <
GetWeatherResult
>
Sunny
</
GetWeatherResult
>
    </
GetWeatherResponse
>
  </
soap:Body
>
</
soap:Envelope
>
 
Security
 
Based on HTTP security
HTTPS
X.509 certificates
 
Manually crypted by developers
 
Firewall friendly
 
Type safe
 
Introduction to Web Services
 
19.-
 
Industrial support
 
Microsoft
Google
Apple
IBM
Hewlett Packard
Intel
 
Introduction to Web Services
 
20.-
 
Demonstration
 
http://www.deeptraining.com/webservices/weather.asmx?wsdl
 
http://localhost/math.asmx?wsdl
 
Introduction to Web Services
 
21.-
 
Demonstration
 
Agenda
 
Overview of Web Services
 
Technologies used
 
How to create a Web Services
 
How to use a Web Services
 
Conclusion
 
Introduction to Web Services
 
22.-
 
Web Services since C# 2.0
 
Web Services
Implemented with ASP.NET
 
Like Web Form page
File extension must be 
.asmx
Contains code but no GUI
 
ASP.NET can automatically generate WSDL
 
Can use all the classes. NET Framework
 
Introduction to Web Services
 
23.-
 
Web Services syntax
 
Code
Inline (in C#)
 
Introduction to Web Services
 
24.-
<
%
@
WebService
 
language
=
"
C#
"
 
codebehind
=
"
MyWebService.cs
"
                            
class
=
"
FirstWebService.MathService
"
 
%
>
<
%
@
WebService
 
Language
="C#"
 
class
="Service1" 
%
>
 
using
 System.Web.Services;
 
[WebService()]
public
 
class
 
Service1
 : System.Web.Services.WebService
{
 
    [WebMethod()]
    
public
 
string
 HelloWorld() {
        return 
"Hello World"
;
    }
}
 
Demo
 
HelloWorld.asmx
MathService.asmx
 
Introduction to Web Services
 
25.-
 
Demonstration
 
Web Services since C# 3.0
 
Windows Communication Framework
Similar to the web service framework 2.0, but
File extension is 
.svc
Based on a communication 
contrat
 
ASP.NET can automatically generate WSDL
 
Can use all the classes. NET Framework
 
Introduction to Web Services
 
26.-
 
WCF syntax
 
First, you must allow the web server to publish a WCF
 
Introduction to Web Services
 
27
 
Web.Config
<?
xml
 
version
=
"
1.0
"
?>
<
configuration
>
 
  <
system.serviceModel
>
    <
behaviors
>
      <
serviceBehaviors
>
        <
behavior
>
          <
serviceMetadata
 
httpGetEnabled
=
"
true
"
/>
          <
serviceDebug
    
includeExceptionDetailInFaults
=
"
true
"
/>
        </
behavior
>
      </
serviceBehaviors
>
    </
behaviors
>
  </
system.serviceModel
>
 
</
configuration
>
 
WCF syntax
 
Contract definitions
 
Introduction to Web Services
 
28
 
Web Service Contract
 
Data Contract
[ServiceContract]
interface
 
IHelloWorldContract
{
    
[OperationContract]
    
int
 Add(
int
 a, 
int
 b);
 
    
[OperationContract]
    HelloMessage HelloWorld();
}
[DataContract]
public
 
class
 
HelloMessage
{
    
[DataMember]
    
public
 
string
 Message
    {
        
get
;
        
set
;
    }
}
 
WCF syntax
 
Contracts implementation
 
Introduction to Web Services
 
29
 
HelloWorld.svc
 
HelloWorld.svc.cs
<%
@
 
ServiceHost
 
Language
="C#"
 
Service
    
=
 
"MyWebService.HelloWorld"
                              
CodeBehind
 
=
 
"HelloWorld.svc.cs" 
%>
public
 
class
 
HelloWorld
 : IHelloWorldContract
{
    
public
 
int
 Add(
int
 a, 
int
 b)
    {
        
return
 a + b;
    }
 
    
HelloMessage
 HelloWorld()
    {
        
return
 
new
 HelloMessage() { Message = 
"Hello World!"
 };
    }
}
 
Agenda
 
Overview of Web Services
 
Technologies used
 
How to create a Web Services
 
How to use a Web Services
 
Conclusion
 
Introduction to Web Services
 
30.-
 
Global overview
 
Find the web service
UDDI
DISCO
 
Find all web method signatures
WSDL
 
Create a Proxy to allow execute remote methods
The proxy is a local object with same methods,
arguments and return values than the Web Services
 
Introduction to Web Services
 
31.-
 
Create a Proxy
 
Introduction to Web Services
 
32
Web Service
math.asmx
Create Local
Proxy Class
 
wsdl.exe
 
http://myserver/math.asmx?wsdl
 
wsdl
Math.cs
Program.cs
 
Execute Add Method
 
Result
 
Create a Proxy
 
Using Wsdl.exe to generate a Proxy 2.0
 
Generation of MathService.cs
Contains a class derived from 
SoapHttpClientProtocol
Proxy place the URL of the Web Services in the constructor
 
Using SvcUtil.exe to generate a Proxy 3.0
 
Generation of HelloWorldContractClient.cs
Contains a class derived from 
ServiceModel.ClientBase
Proxy place the URL of the Web Services in App.config
 
Introduction to Web Services
 
33.-
wsdl http://localhost/MathService.asmx?WSDL
SvcUtil http://localhost/HelloWorld.svc?WSDL
 
Create a Proxy 
with Visual Studio
 
Use Add Web Reference to a WSDL search
or to find a URL via Web Services
 
This builds a proxy, and you
can immediately start the Web Services
Visual Studio.NET calls 
wsdl.exe
 for you
 
Introduction to Web Services
 
34.-
 
Web Methods Testing
 
ASMX
A 
ASMX
 web service
is checkable directly
in Internet Explorer.
 
 
 
SVC
A 
SVC
 web service is checkable via "WCF Test Client"
http://msdn.microsoft.com/en-us/library/bb552364.aspx
 
Introduction to Web Services
 
35
 
Demos
 
Trasys Exchange Web Services
https://webmail.trasys.be/ews/services.wsdl
Display all unread mails
 
Introduction to Web Services
 
36.-
 
Démonstration
 
Conclusion
 
Technologies
Overview
 
How to create a
web service
 
How to consume
a web service
 
Demonstrations
 
Introduction to Web Services
 
37
 
Ressources
 
SOAP Specification
http://www.w3.org/TR/SOAP/
 
WSDL Specification
http://www.w3.org/TR/wsdl
 
A Quick Introduction to WSDL
http://msdn.microsoft.com/en-us/library/ms996539.aspx
 
UDDI
http://www.uddi.org - http://uddi.microsoft.com
 
Microsoft .NET
http://www.microsoft.com/net
 
Introduction to Web Services
 
38.-
Slide Note
Embed
Share

Explore the essential aspects of web services in this comprehensive guide by Denis Voituron. Understand the significance of web services, learn to create and debug them using .NET Framework and Visual Studio. Delve into topics like distributed applications, portals, service architecture, and practical examples. Gain insights into the role of web services in modern businesses and their applications across diverse industries.


Uploaded on Sep 06, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to Web Services Ir Denis VOITURON http://www.dvoituron.be Version 3.1

  2. Goals Understand the importance ofWeb Services Basic notions ofWeb Services Being able to create and debug aWeb Service Using the .NET Framework UsingVisual Studio. Introduction to Web Services 2.-

  3. Agenda Overview ofWeb Services Technologies used How to create aWeb Services How to use aWeb Services Conclusion Introduction to Web Services 3.-

  4. The business today Companies Sharing business processes Working together Quickly With internet Including heterogeneous system Introduction to Web Services 4.-

  5. Solutions Distributed applications Internet Web Sites (portals) Web Services oData, Json Introduction to Web Services 5.-

  6. Distributed applications Client / Server Model Not extensible Not secure Based on distributed object model Examples COM, CORBA, Java RMI Not internet based Not interoperable No standards Introduction to Web Services 6.-

  7. Portals Ads Mail Other Svcs Calendar Weather Finance News Introduction to Web Services 7.-

  8. Web Services A programmable application component that is accessible via standard Internet protocols Web Methods HTTP Communicate using open protocols W3C Self-contained and self-describing XML Usable by other applications Heterogeneous Introduction to Web Services 8

  9. Architecture Service Broker UDDI WSDL WSDL f(x) SOAP Source: Wikipedia Service Requester Service Provider Introduction to Web Services 9

  10. Example How to convert Number to Roman http://www.ebob42.com/cgi-bin/Romulan.exe/wsdl/Iroman What is the weather for a given city http://www.deeptraining.com/webservices/weather.asmx?wsdl Using Google, Bing, Yahoo, Introduction to Web Services 10

  11. Agenda Overview ofWeb Services Technologies used How to create aWeb Services How to use aWeb Services Conclusion Introduction to Web Services 11.-

  12. XML Connecting Applications Connectivity Presentation Connect the Web Browse the Web Program the Web Introduction to Web Services 12.-

  13. Protocols used Publish & Find Services Find Services on server Formal Service Descriptions UDDI DISCO WSDL Service Interactions Universal Data Format Ubiquitous Communica- tions SOAP XML Internet Simple, Open, Broad Industry Support Introduction to Web Services 13

  14. Architecture Service Broker UDDI 2 WSDL WSDL 1 3 f(x) SOAP Source: Wikipedia 4 Service Requester Service Provider Introduction to Web Services 14

  15. XML - eXtended Markup Language Set of rules for encoding documents in human readable form XML Declaration Unicode character Tag or Element Attribute <?xml version="1.0" encoding="utf-8" ?> <note sendBy="Mail"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body> Don't forget me this weekend! </body> </note> Introduction to Web Services 15.-

  16. WSDL Web Services Description Language Describing the functionality offered by a Web service How the service can be called What parameters it expects What data structures it returns Introduction to Web Services 16.-

  17. WSDL Description of GetWeather(string city) http://www.deeptraining.com/webservices/weather.asmx?wsdl ... <soap:element name="GetWeather"> <soap:complexType> <soap:sequence> <soap:element minOccurs="0" maxOccurs="1" name="City" type="soap:string"/> </soap:sequence> </soap:complexType> </soap:element> <soap:element name="GetWeatherResponse"> <soap:complexType> <soap:sequence> <soap:element minOccurs="0" maxOccurs="1" name="GetWeatherResult" type="soap:string"/> </soap:sequence> </soap:complexType> </soap:element> ... Introduction to Web Services 17.-

  18. SOAP request and SOAP result Call Web Method: GetWeather(string city) <soap:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetWeather> <City>Brussels</City> </GetWeather> </soap:Body> </soap:Envelope> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" <soap:Body> <GetWeatherResponse> <GetWeatherResult>Sunny</GetWeatherResult> </GetWeatherResponse> </soap:Body> </soap:Envelope> Introduction to Web Services 18.-

  19. Security Based on HTTP security HTTPS X.509 certificates Manually crypted by developers Firewall friendly Type safe Introduction to Web Services 19.-

  20. Industrial support Microsoft Google Apple IBM Hewlett Packard Intel Introduction to Web Services 20.-

  21. Demonstration http://www.deeptraining.com/webservices/weather.asmx?wsdl http://localhost/math.asmx?wsdl Introduction to Web Services 21.-

  22. Agenda Overview ofWeb Services Technologies used How to create aWeb Services How to use aWeb Services Conclusion Introduction to Web Services 22.-

  23. Web Services since C# 2.0 Web Services Implemented with ASP.NET Like Web Form page File extension must be .asmx Contains code but no GUI ASP.NET can automatically generateWSDL Can use all the classes. NET Framework Introduction to Web Services 23.-

  24. Web Services syntax Code <%@WebService language="C#" codebehind="MyWebService.cs" class="FirstWebService.MathService" %> Inline (in C#) <%@WebService Language="C#" class="Service1" %> using System.Web.Services; [WebService()] public class Service1 : System.Web.Services.WebService { [WebMethod()] public string HelloWorld() { return "Hello World"; } Introduction to Web Services } 24.-

  25. Demo HelloWorld.asmx MathService.asmx Introduction to Web Services 25.-

  26. Web Services since C# 3.0 Windows Communication Framework Similar to the web service framework 2.0, but File extension is .svc Based on a communication contrat ASP.NET can automatically generateWSDL Can use all the classes. NET Framework Introduction to Web Services 26.-

  27. WCF syntax First, you must allow the web server to publish aWCF Web.Config <?xml version="1.0"?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> includeExceptionDetailInFaults="true"/> </configuration> Introduction to Web Services 27

  28. WCF syntax Contract definitions Web Service Contract Data Contract [DataContract] public class HelloMessage { [DataMember] public string Message { get; set; } } [ServiceContract] interface IHelloWorldContract { [OperationContract] int Add(int a, int b); [OperationContract] HelloMessage HelloWorld(); } Introduction to Web Services 28

  29. WCF syntax Contracts implementation HelloWorld.svc <%@ ServiceHost Language="C#" Service = "MyWebService.HelloWorld" CodeBehind = "HelloWorld.svc.cs" %> HelloWorld.svc.cs public class HelloWorld : IHelloWorldContract { public int Add(int a, int b) { return a + b; } HelloMessage HelloWorld() { return new HelloMessage() { Message = "Hello World!" }; } } Introduction to Web Services 29

  30. Agenda Overview ofWeb Services Technologies used How to create aWeb Services How to use aWeb Services Conclusion Introduction to Web Services 30.-

  31. Global overview Find the web service UDDI DISCO Find all web method signatures WSDL Create a Proxy to allow execute remote methods The proxy is a local object with same methods, arguments and return values than the Web Services Introduction to Web Services 31.-

  32. Create a Proxy wsdl.exe http://myserver/math.asmx?wsdl Create Local Proxy Class Web Service math.asmx wsdl Math.cs Execute Add Method Program.cs Result Introduction to Web Services 32

  33. Create a Proxy UsingWsdl.exe to generate a Proxy 2.0 wsdl http://localhost/MathService.asmx?WSDL Generation of MathService.cs Contains a class derived from SoapHttpClientProtocol Proxy place the URL of theWeb Services in the constructor Using SvcUtil.exe to generate a Proxy 3.0 SvcUtil http://localhost/HelloWorld.svc?WSDL Generation of HelloWorldContractClient.cs Contains a class derived from ServiceModel.ClientBase Proxy place the URL of theWeb Services in App.config Introduction to Web Services 33.-

  34. Create a Proxy with Visual Studio Use AddWeb Reference to aWSDL search or to find a URL viaWeb Services This builds a proxy, and you can immediately start theWeb Services Visual Studio.NET calls wsdl.exe for you Introduction to Web Services 34.-

  35. Web Methods Testing ASMX A ASMX web service is checkable directly in Internet Explorer. SVC A SVC web service is checkable via "WCF Test Client" http://msdn.microsoft.com/en-us/library/bb552364.aspx Introduction to Web Services 35

  36. Demos Trasys Exchange Web Services https://webmail.trasys.be/ews/services.wsdl Display all unread mails Introduction to Web Services 36.-

  37. Conclusion Technologies Overview Service Broker How to create a web service UDDI WSDL WSDL How to consume a web service f(x) SOAP Service Requester Service Provider Demonstrations Introduction to Web Services 37

  38. Ressources SOAP Specification http://www.w3.org/TR/SOAP/ WSDL Specification http://www.w3.org/TR/wsdl A Quick Introduction to WSDL http://msdn.microsoft.com/en-us/library/ms996539.aspx UDDI http://www.uddi.org - http://uddi.microsoft.com Microsoft .NET http://www.microsoft.com/net Introduction to Web Services 38.-

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#