|
1
|
- Paul Litwin
- Deep Training
- paull@deeptraining.com
|
|
2
|
- Developer
- Focus: ASP, ASP.NET, VB, SQL Server…
- MCSD, Microsoft MVP
- Trainer & Co-Founder
- Conference Chair
- Microsoft ASP.NET Connections
- Author/Editor
- Editor of asp.netPRO Magazine
- Author/co-author of a dozen books, including…
|
|
3
|
- This session adapted from the Web Services chapters in ASP.NET For
Developers
By Mike Amundsen and Paul Litwin
|
|
4
|
- Understanding the Web Services Model
- Creating an ASP.NET Web Service
- WSDL and Web Service Clients
- Working with Complex Types
- Creating and Consuming Web Services with Visual Studio .NET
- Creating an ASP Classic Client with the SOAP Toolkit
|
|
5
|
|
|
6
|
- What is it?
- A programmable application component accessible via standard Web
protocols
- Built on top of SOAP (Simple Object Access Protocol)
- Examples: stock quote, weather, and work flow, team collaboration
- Makes building distributed applications easy
|
|
7
|
- SOAP (Simple Object Access Protocol)
- Explicit serialization (HTTP + XML description) protocol used in
service exchanges
- WSDL (Web Service Description Language)
- XML language describing the location and interfaces a particular
service supports –
the client’s contract
- DISCO (Discovery)
- XML document describing (URI) of service
- UDDI (Universal Description Discovery
and Integration)
- Yellow pages directory for services
|
|
8
|
|
|
9
|
- While you can build Web Services using .NET, Web Services are not tied
to .NET
- Web Service standards are guided by W3C and other standards bodies
- Web Services and their clients can be built with a variety different
tools on a vast variety of platforms
- Web Services == Interoperabilty
|
|
10
|
|
|
11
|
- Author .asmx file containing class & methods
- Add WebService directive
<%@ WebService class="class" %>
- Import System.Web.Services namespace
- Visual Basic: Imports System.Web.Services
- C#: using System.Web.Services;
- Add a class that inherits from WebService class
- Visual Basic: : Inherits
WebService
- C#: : WebService
- Mark methods with WebMethod attribute
- Visual Basic: <WebMethod()>
- C#: [WebMethod()]
|
|
12
|
|
|
13
|
- If you browse to an .asmx page, ASP.NET automatically generates a help
page that…
- describes all the Web Service’s operations (methods)
- lets you browse the WSDL (Service Description) of the service
- lets you test the Web Service using a sample form and HTTP GET protocol
|
|
14
|
- WebService (attribute of class)
- Description – document service
- Name – change SOAP name for service
- Namespace – create unique namespace for service
- WebMethod (attribute of method)
- Description – document method
- BufferResponse – set to False to turn off buffering
- CacheDuration – set to True to cache responses
- EnableSession – set to True to enable Session support
- MessageName – change SOAP name for message
- TransactionOption – set to enable transaction support
|
|
15
|
|
|
16
|
|
|
17
|
- Web Services Description Language (WSDL)
- Standard XML language for describing Web Services
- Submitted to W3C by Microsoft, IBM
(http://www.w3c.org/TR/wsdl)
- Replaces SDL (used in .NET Beta 1)
- WSDL is the key to creating
clients
- Generated automatically by
.NET Web Services
|
|
18
|
|
|
19
|
- Uses proxy and SOAP protocol to communicate with Web Service
- Steps
- Use wsdl utility to create local proxy
- Compile proxy using vbc (or csc)
- Place compiled proxy assembly in bin folder of Web
- Create client
- Import proxy namespace, code to proxy’s properties and methods
|
|
20
|
|
|
21
|
|
|
22
|
|
|
23
|
- ASP.NET Web Services automatically serialize complex types into XML that
can be retrieved by just about any client
- If using an ASP.NET client, however, complex types will be de-serialized
back into original type
|
|
24
|
|
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
- Create a Project of type ASP.NET Web Service
- Basic skeleton of Web Service is created for you
- Add Web Methods and go!
|
|
30
|
- Create new ASP.NET Web Application (or Windows Form app or another Web
Service app…)
- Right-click on References in Solution Explorer and select Add Web
Reference
- Enter http address of service in dialog
- After navigating to service (.asmx), click on enabled Add Reference
button
- Proxy is automatically generated for you
- Full IntelliSense support for Web Services too
|
|
31
|
- Web Service will added to a namespace using the name of the Web Server
(localhost for the local machine)
- Example of coding against local service
|
|
32
|
|
|
33
|
- Unlike ASP.NET, ASP Classic doesn’t know how to talk to Web Services
using SOAP
- So, you can either handle SOAP details yourself using lots and lots of
code, or download the Microsoft Soap Toolkit 2.0
- The toolkit, amongst other things, includes a COM component that serves
as a Web Service proxy that you can call from any COM-compliant app,
including ASP classic
|
|
34
|
- You use Microsoft Soap Toolkit 2.0 soapClient object to call Web Service
|
|
35
|
- Steps
- Download and install Microsoft SOAP Toolkit 2.0
- Create ASP page
- Set ClientProperty("ServerHTTPRequest") to True
- Use soapClient object to call Web Service
|
|
36
|
- A Web Service is a programmable application component accessible via
standard Web protocols built on top of SOAP
- You can easily create and consume Web Services using ASP.NET
- It’s even easier to create and consume Web Services using Visual Studio
.NET
- WSDL is the key to creating Web Service clients
- Web Services serialize and de-serialize complex data types
- You can create an ASP Classic Web Service client using the Microsoft
SOAP Toolkit
|