You are on page 1of 25

Web services

• Web Services function primarily through


XML in order to pass information back and
forth through the Hypertext Transfer
Protocol (HTTP). Web Services are a vital
part of what the .NET Framework offers to
programmers. XML-based data transfer is
realized, enabling primitive types,
enumerations, and even classes to be
passed through Web Services to the
application performing the request.
• Web Services are objects and methods that can
be invoked from any client over HTTP. Web
Services are built on the Simple Object Access
Protocol (SOAP). Unlike the Distributed
Component Object Model (DCOM) and Common
Object Request Broker Architecture (CORBA),
SOAP enables messaging over HTTP on port 80
(for most Web servers) and uses a standard
means of describing data. SOAP makes it
possible to send data and structure easily over
the Web. Web Services capitalizes on this
protocol to implement object and method
messaging. Web Services are easy to create in
VS.NET
Communication between Servers
WSDL
WSDL

• WSDL is an XML-based language that describes Web Services.


It is the composite of work done by Ariba, IBM, and Microsoft.
Currently, it only supports SOAP as a messaging protocol.
• WSDL describes the Web Service method interfaces
thoroughly enough for it to be used to create proxy
methods that enable other classes to invoke its members
as if they were local methods. IBM and Microsoft both
have WSDL command line utilities available that do just
that. IBM does it for Java, and Microsoft does it for
Visual Studio. VS.NET has this ability built into the GUI.
In VS.NET, we simply right-click add Web Reference
and select the service we want to generate a proxy class
for. Here is an example of a WSDL file for a Web
Service: getCategories.wsdl.This file is auto-generated
by the .NET Framework.
Type Marshalling

• Type marshalling refers to the translation of data types


from an application or database as it is mapped to a
SOAP data type. When any data Type, object, method,
or string (xml, or a simple string) is passed as a SOAP
request or response, it is automatically converted into an
XML representation of itself. Since any programming
language can use SOAP, SOAP has defined its own set
of data types. When data is passed in a SOAP envelope
its data types are translated or converted to a SOAP
equivalent. This enables different languages with
different names for similar data types to communicate
effectively. The data types supported when using Web
Services include:
• ■ Standard primitive types: String, char,
Boolean, byte, single, double, DateTime, int16,
int32, int 64, Uint16, and so on.

• Enum Types Enumerations like enum weekday


{sun=0, mon=1, tue=2, wed=3, thu=4, fri=5, sat
=6}
• Arrays of Primitives or Enums
MyArray[ 5,7 ] is represented as:
<ArrayOfInt>
<int>5</int>
<int>7</int>
</ArrayOfInt>
• Classes and Structs
• struct Order( OrderID, Price ) is
represented as:
<Order>
<OrderID>12345</OrderID>
<Price>49.99</Price>
</Order>
• Arrays of Classes (Structs)
• MyArray Orders( order1, order2 ) may be
represented as:
• <ArrayOfOrder>
• <Order>
• <OrderID>int</OrderID>
• <Price>double</Price>
• </Order>
• <Order>
• <OrderID>int</OrderID>
• <Price>double</Price>
• </Order>
• </ArrayOfOrder>
An Overview of the
System.Web.Services Namespace
• 􀀻 System.Web.Services is .NET Framework’s namespace of
classes that enable .NET Web Services.The three primary
subclasses or subnamespaces are:
• 1. System.Web.Services.Description Classes that support WSDL,
used to define the methods, parameters, and datatypes of Web
Services.

• 2. System.Web.Services.Discovery Classes that support UDDI


and the generation of WSDL proxies for Web Service clients.

• 3. System.Web.Services.Protocols Classes that support the


generation and customization of Web service protocols, and can be
used for things such as creating custom SOAP headers.
Q: Why replace COM objects with Web
Services?

• Web Services have a platform neutral


interface.This enables Web Services to be
easily utilized by multiple clients of different
platforms developed with different
programming languages. Note that existing
COM components can be wrapped by Web
Services.
The Role of SOAP

• SOAP stands for Simple Object Access


Protocol. SOAP was designed with the
following three goals in mind:
• ■ It should be optimized to run on the
Internet.
• ■ It should be simple and easy to
implement.
• ■ It should be based on XML.
• SOAP is an open Internet standard. It was
originally proposed by IBM, Ariba, and
Microsoft, and the W3C has taken on the
initiative to develop it further. The current
version is SOAP 1.1 (April 2000).

SOAP, somewhat contrary to its name, is


fundamentally just a protocol that lets two systems—
a client and a server exchange data. Of course, the
client system may be, and often is, just another
server machine, not a human end user.
• SOAP supports two message patterns: the first
is a simple one-way exchange, where a client
issues a request against a server, and will not
receive an answer back. We focus in this
chapter on the second message pattern, which
consists of a request-response interaction,
familiar to all Web developers. A client issues an
HTTP request for a resource on a server, and
the server replies by sending an HTTP
response. SOAP adds to that a standard way to
pass data back and forth, including a standard
way to report errors back to the client.
• SOAP has two faces. On the one hand,
stressing the second item in the preceding
list, you can look at it as a remote
procedure call (RPC) protocol familiar to
anybody who has worked with distributed
object models in the past. On the other
hand, putting more emphasis on the first
item, you can consider it a standardized
way to interchange (XML) documents.
WSDL AND UDDI
• Web Service Description Language
(WSDL) An XML format to describe how a
particular Web Service can be called, what
arguments it takes, and so on.
• Universal Description, Discovery, and
Integration (UDDI) A directory to publish
business entities and the Web Services
they offer, and where you can find those
services. UDDI is implemented as a Web
Service itself.
Web Service Standards

• SOAP, the wire transport protocol


• WSDL to describe Web Services
• DISCO to discover
• UDDI to publish Web Services
• Web Services is a new technology
designed primarily to facilitate
communications between enterprises on
the Internet. Web Services are supported
by all major software vendors, and are
based on Internet standards:
• HTTP as the network protocol (among
others)
• XML to encode data
• SOAP as the wire transport protocol
• WSDL to describe Web Service syntax
• UDDI to publish Web Service information
• SOAP based Web Services as an RPC (Remote
Procedure Call) mechanism, you can use SOAP to
exchange any type of XML documents.We explained the
basic structure of the SOAP protocol:
• SOAP exchanges an XML document called a SOAP
Envelope, which has two parts:
1. The SOAP Header, which is designed to be extended to
include application- specific metadata, such as security-
or session-related identifiers.
2. The SOAP Body, which contains the necessary
information to find a class and method on the server to
handle the Web Service request, in addition to
parameter data that may be necessary to process such a
• request.
• Describing Web Services—WSDL In the world
of Web Services, the role of a type library is
taken by the WSDL description of a Web
Service.
• WSDL is a complex standard that is still
undergoing changes, and discussing it in detail
is beyond the scope of this book; you can find
more information about WSDL, including the
actual WSDL specification,
• Discovering Web Services—DISCO
• 􀀻DISCO guides clients to the WSDL files
describing the call syntax of Web Services.
• 􀀻 Microsoft Visual Studio.NET automatically
adds and maintains a file with extension .vsdisco
to Web Service projects.
• 􀀻 You can also statically generate a DISCO file
using the disco.exe tool found at %ProgramFiles
%\Microsoft.NET\FrameworkSDK\Bin\.This is the
same tool that also outputs the WSDL
description.
Publishing Web Services—UDDI
• UDDI is a Web Service itself, and it allows
businesses and individuals to publish
information about themselves and the
Web Services they are offering.
• 􀀻 The UDDI registry of Web Services is
still in its infancy, and quite frankly, there
are not a lot of useful Web Services out
there at the time of 􀀻 If you want to
programmatically interface with UDDI, you
can get the Microsoft UDDI SDK, which
consists of a series of both COM and .NET
classes to interact with the UDDI registry;

You might also like