You are on page 1of 31

Web Services

Keith Pijanowski
.Net Developer Evangelist
Microsoft Corporation
KeithPij@microsoft.com
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

How do we talk? (WSDL)


Web
http://yourservice.com/?WSDL
Service
Consumer XML with service descriptions

Web
Let me talk to you (SOAP) Service
http://yourservice.com/svc1
XML/SOAP BODY

Design-Time or Runtime Runtime


Web Services Architecture
Screen Scraping example

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# …

Common Language Specification

Visual Studio .NET


ASP .NET Windows
Web Forms Web Services
Mobile Internet Toolkit
Forms

ADO .NET and XML

Base Class Library

Common Language Runtime

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

 Default: Simple Object Access


Protocol (SOAP)
Structures
Enumerations
Classes
XML DataSets
Arrays of anything
14
Web Services in .NET
Tools
 On the Server Side
 Attributed Code
 Generates WSDL
 Generates .vsdisco
 Generates HTML text page
 Supports breakpoints, tracing, etc.
 On the Client Side
 Generates proxy class with sync and
async calls
 Supports “Step-Into” across web service
call 15
Demonstration #1

Return Data from a Web Service


Consume a Web Service

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

 Use Existing ASP.NET Counters


 Create Application Specific Counters

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

Public Class MyHeader : Inherits SoapHeader


Public Username As String
Public Password As String
End Class

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

You might also like