Web Services
Web Services
Keith Pijanowski
.Net Developer Evangelist
Microsoft Corporation
[email protected]
Agenda
Why Web Service?
Web Services Architecture
Web Services in .NET
Debugging Web Services
Advanced Features
2
Islands Of Software
?
?
?
?
3
Next Gen Web Applications
Applications Become
Other Programmable Web Services Public Web
Services Services
XML
BizBizLogic & XML
Biz
WebLogic
Tier Service .NET
Smarter
Smarter Tier Logic
Clients XML XML Services
Clients
Internal
Standard OS XML Services
Standard
Browsers HTML OSOS
Browsers Services
Services
Services
Smarter XML XML Servers
Smarter
Devices
Devices Open Internet Data, Hosts
Communications Protocols
Richer, More (HTTP, SMTP, XML, SOAP) Applications Leverage
Productive User Globally-Available
Experience Federated Web Services
4
Agenda
Why Web Service?
Web Services Architecture
Web Services in Visual Studio .NET
Debugging Web Services
Advanced Features
5
Web Services Architecture
Find a Service
http://www.uddi.org
UDDI
Link to DISCO or WSDL document
Web
Let me talk to you (SOAP) Service
http://yourservice.com/svc1
XML/SOAP BODY
7
Agenda
Why Web Service?
Web Services Architecture
Web Services in .NET
Debugging Web Services
Advanced Features
8
Visual Studio .NET and the
.NET Framework
VB C++ C# J# …
Operating System
9
Web Services in .NET
What makes a Web Service?
Web Service (ASMX in ASP .NET)
Invoke Web Service methods
ASMX
10
Web Services in .NET
What makes a Web Service?
Web Service (ASMX in ASP+)
– Invoke Web Service methods
Web Service Description Language (WSDL)
– Describe Web Services
– Describes dependencies (e.g., DataSets / XSD)
ASMX
WSDL
XSD
11
Web Services in .NET
What makes a Web Service?
Web Service (ASMX in ASP+)
– Invoke Web Service methods
Web Service Description Language (WSDL)
– Describe Web Services
– Describes dependencies (e.g., DataSets / XSD)
Discovery Documents (DISCO)
– Publish Web Services
ASMX
WSDL
DISCO XSD
WSDL
12
Web Services in .NET
What makes a Web Service?
Web Service (ASMX in ASP+)
– Invoke Web Service methods
Web Service Description Language (WSDL)
– Describe Web Services
– Describes dependencies (e.g., DataSets / XSD)
Discovery Documents (DISCO)
– Publish Web Services
• UDDI
ASMX
WSDL
DISCO XSD
UDDI WSDL
DISCO
13
Web Services in .NET
Protocols
Basic: HTTP Get and HTTP Post
Primitives (integers, strings, etc)
Arrays of primitives
16
Agenda
Why Web Service?
Web Services Architecture
Web Services in .NET
Debugging Web Services
Advanced Features
17
Debugging Web Services
Options
Interactive Debugging
Set Breakpoints
Building a program database
Attach to the correct process
Instrumenting Web Services
Debug Class
Trace Class
Event Log
Performance Counters
18
Debugging Web Services
Debug and Trace Class
Properties
AutoFlush IndentSize
IndentLevel Listeners
Methods
Assert Unindent
Close Write
Fail WriteLine
Flush WriteLineIf
Indent
19
Debugging Web Services
Event Log - At A Glance
If Not EventLog.SourceExists(“My Web”) then
EventLog.CreateEventSource(“My Web”, _
“Application”)
End if
EventLog.WriteEntry(“My Web”, _
“Account Info Requested”, _
EventLogEntryType.Information)
20
Debugging Web Services
Performance Counters
Real Time Information
Take Advantage of existing
infrastructure
Monitoring
Reporting
21
Agenda
Why Web Service?
Web Services Architecture
Web Services in .NET
Debugging Web Services
Advanced Features
22
Advanced Features
Asynchronous Calls
Synchronous Programming Model
Foo(Param1, Param2) As String
Asynchronous Programming Model
BeginFoo(Param1, Param2, Callback)
Callback(AsyncResult)
EndFoo(AsyncResult) As String
23
Advanced Features
SOAP Headers
<soap:Envelope xmlns:soap=“http://schemas.xml ..
<soap:Header>
<!—Optional header information. -- >
<username>Keith</username>
<password>Test</password>
</soap:Header>
<soap:Body>
<! -- Message goes here. -- >
</soap:body>
</soap:Envelope>
24
Advanced Features
SOAP Headers – Server Code
Make a Class That Inherits SoapHeader
Add Custom Properties
Associate This With Your Web Service
25
Advanced Features
SOAP Headers – Client Code
Create Instance of the Header Class
Populate With Values
Attach To Web Service Object
Call Method
WebServ ws = new WebServ();
MyHeader a = new MyHeader();
a.Username = "admin";
a.Password = "password";
ws.MyHeader = a;
ws.DoSomething(); 26
Soap Headers
Demonstration #2
27
Advanced Features
SoapExtension
Used for More Advanced Functionality
Intercept Calls to a Web Service
Intercept Calls to a Web Method
Pre and Post Processing
Create a class derived from
SoapExtension
Create an Attribute derived from
SoapExtensionAttribute
Apply attribute to method of service
class
28
Session Summary
Web Services Are The Building Blocks
For The Next Generation Of The Internet
Gives Client Access to any kind of Data
Make Business-to-Business Easy
Visual Studio .NET Provides Great Tools
29
Questions And Answers
30