82
Company Confidential 1 XML Architecture and Web Services

Company Confidential 1 XML Architecture and Web Services

Embed Size (px)

Citation preview

Company Confidential

1

XML Architecture and Web Services

Objectives

• To understand the Underlying Technologies of XML Web Services

– Web Service and its Features– Why Web Services– XML Web Services Infrastructure– XML Web Service Workflow– XML Web Services Infrastructure– XML Web Services Architecture– Working with XML Dataset Object– Working with XML Data and Web Server Control– Reading, Transforming and Displaying XML Data– Creating Web Services– Deploying Web Services

Objective

• Consuming XML Web Services– Explaining the structure of a Web Service Description

Language (WSDL) document. – Explaining the XML Web services discovery process. – Locating service contracts by using Disco.exe. – Generating XML Web service proxies by using

Wsdl.exe. – Implementing an XML Web service consumer by using

Visual Studio .NET. – Invoking an XML Web service synchronously and

asynchronously by using an XML Web service proxy.– Explaining the role of UDDI in XML Web services

Limited Technologies for Web

• Distributed Object Model (DOM)

– Tightly coupled Service and Consumer

• Need for homogeneous infrastructure

• Versioning Problem

• CORBA

– Server object implementation not portable

• COM

– Limited support on Non-Windows platforms

• EJB (Enterprise JavaBeans)

– Is tied to only Java Language

• Purely interactive Web

Web Service????

CodeCode

Remote ServerRemote Server ClientClient

CodeCode

Running on LinuxRunning on LinuxWindows 2000Windows 2000

XML/HTTPXML/HTTP

• Web Service is any piece of software that makes itself available over the internet/intranet and can be called from any client.– Code that can be accessed by any other piece of code– independent of any Programming language or platform– Web Services are methods that can be invoked from any client that

support HTTP or SOAP.

Web Services - Features

• XML Web service is a component that implements program logic and provides functionality for disparate applications.

• These applications use standard protocols, such as HTTP, XML, and SOAP, to access the functionality.

• XML Web services use XML-based messaging to send and receive data, which enables heterogeneous applications to interoperate with each other.

• You can use XML Web services to integrate applications that are written in different programming languages and deployed on different platforms.

Web Services -Features

• In addition, you can deploy XML Web services within an intranet as well as on the Internet.

• While the Internet brings users closer to organizations, XML Web services allow organizations to integrate their applications.

• One important feature of the XML Web services based computing model is that a client need not know the language in which XML Web services are implemented.

• The client just needs to know the location of an XML Web service and the methods that the client can call on the service.

Web Services- Evolution of the Web

Generation 1Static HTML

HTML

Generation 2Web Applications

HTML

HTML, XML

HTML, XML

Generation 3Web Services

Typical Web Services Usage

• Applications that are either too difficult or too expensive to implement yourself such as:– Credit Card Validation– Financial Account Management– Stock Quotes

• Applications that provide commonly needed functionality for other services such as:– User Authentication– Usage Billing– Usage Auditing

• e.g. Microsoft Passport (hotmail account)

Typical Web Services Usage

• Applications that integrate business systems with partners or other business systems within the organization or out of the organization.– Financial Statements – Stock Status – (Balance Sheets, Income Statements etc)

Why Web Services? B 2 C scenario

HR

Employee Database

New

Employee

Details

Systems

View

new

employees

strength

Computer

Manufacturer’s

Marketing Team

PC’s Requirement

Manufacturer’s Database

Customer

request

Why Web Services? B 2 B scenario

HR

Employee Database

New

Employee

Details

Manufacturer’s

Database

PC Requirements

Application

Application

XML Web Service Workflow

• .

INTERNETINTERNET

WeatherXML Web Service

WeatherXML Web Service

Exchange RateXML Web ServiceExchange Rate

XML Web Service

Pick your destination:

The weatherForecast calls for:

The exchange rate is:

We can fly you there for only:

Bahrain

0.3760

$1,999.98

AirfareDatabaseAirfare

Database

AirfareXML Web Service

AirfareXML Web Service

Travel SiteTravel Site

Web Services

Web Service

Language A on Platform B

Web Service

Language X on Platform M

Web Service

Language Y on Platform NWeb Service

Language Z on Platform O

SOAP on Protocol 1

SOAP on Protocol 2

SOAP on Protocol 3

Basics of Web Services

• Exposing services to other processes– Applications (Intranet or Internet)– Different Clients– Many Devices– Distribution and Integration of application Logic

• Black Box– Like Components, implementation is hidden– Reusability

• Open Standards– HTML (HyperText Markup Language)– XML (Extensible Markup Language)– SOAP (Simple Object Access Protocol)

• Based on ASP .Net Web Services Model– Simplifies developing Web Services.

Web Services

• Web Services are Loosely Coupled, Contracted Components that communicate via XML based interface

• Loosely Coupled– Web Services and the programs that invoke them can

be changed independently of each other• Contracted

– Web Service’s behavior, input and output parameters, and how to bind it are publically available

• Components– Implementation of each component is hidden– Each component’s functionality is known only through

the interface it exposes.

Web Service

Web Web SiteSiteWeb Web

ServiceService

HTMLHTML

ClientClient

XML

XML

ClientClientXMLXML

Web Web ServiceService

XMLXML

Web Web ServiceService

XMLXML

XM

LX

ML

XML

XML

ClientClientXMLXML

Web Web ServiceService

XMLXML

Web Web ServiceService

XMLXML

XM

LX

ML

Web Service Architecture

Web ServiceWeb ServiceRequestRequest

ResponseResponse

Bu

siness

Bu

siness

Co

mp

on

ent

Co

mp

on

ent

CO

M C

om

po

nen

tC

OM

Co

mp

on

ent

Facad

eF

acade

WebWebServiceService

Data A

ccessD

ata Access

Listen

erL

istener

XML Web Services Infrastructure

• eXtensible Markup Language (XML) – Allows data interchange regardless of the hardware and

software platform used to develop the application. • Simple Object Access Protocol (SOAP)

– Is a standard communication protocol for interchanging information in a structured format in a distributed environment.

• Web Services Description Language (WSDL) – Is an XML vocabulary that describes the methods that are

exposed by a Web service. • Universal Description Discovery and Integration (UDDI)

– Is used as a standard mechanism to register and discover a Web service provided by various Web service providers

XML Web Services Infrastructure

ClientApplication

UDDI WSDL Document

Web ServiceCommunication Through SOAP Message

DescribesLocates a

Web Service

XML Web Services Architecture

• .

XML Web Services Architecture

XML Web Services Architecture

• The client creates an object of the XML Web service proxy class on the same computer on which the client resides.

• The client calls a method on the proxy object.• The XML Web services infrastructure on the client system

serializes the method call and arguments into a SOAP message and sends it to the XML Web service over the network.

• The infrastructure on the server on which the XML Web service resides deserializes the SOAP message and creates an instance of the XML Web service. The infrastructure then calls the method with the arguments on the XML Web service.

• The XML Web service executes the method and returns the value with any out parameters to the infrastructure.

XML Web Services Infrastructure

UDDI

ClientApplication

Web Service

1 Client tries to find an XML Web Service

2 A URL to a discovery document is linked

3 Discovery document is requested by client

4 Web Server returns the discovery document

5 Description of Web Service is requested by Client

6 Service Description is returned

7 Client request the XML Web Service

8 Service response is returned

Creating Web Services –The Manual Approach

• At the server

– One must process the XML and dispatch the request to appropriate object

– Generate response XML to send to caller

• At the client

– One must generate XML request to send to server

– Process XML response sent back from server

• Both ends require a lot of reading and writing XML

Creating Web Services – The Framework Approach

• At the server– Create a class with methods

– XML parsing and dispatching is handled

– Framework automatically builds a stub to handle inbound and outbound XML

• At the client– Make a web reference

– Make method calls to an object

– Framework automatically builds a proxy to handle inbound and outbound XML

Working with Dataset Objects

• The ADO.NET DataSet object has several XML related methods. The DataSet object is actually stored natively as XML.

• The first four of the Dataset object’s XML-related methods we will consider here– GetXml – Returns the XML representation of dataset

object’s content as string– GetXmlSchema – Return the schema for the XML

representation of the Dataset Object’s contents as a string. The schema is in W3C (XSD) format

Working with Dataset Objects

– WriteXml – Writes the DataSet object’s contents as an XML document either directly to disk file or as textwriter etc.

– WriteXmlSchema – Write the structure of the Dataset object’s contents as an XSD Schema document either directly to a disk file or as textwriter etc.

Creating XML from a Database Table

• Inserting Into Xml file Dim con As New OleDb.OleDbConnection, DA As OleDb.OleDbDataAdapter, ds As New

DataSet Dim st As String, xPath As String, XSPath As String

con.ConnectionString = "Provider=SQLOLEDB.1;User ID=sa;Data Source=BSLS034;Initial Catalog=Raj_tech"

con.Open() st = "Select * from student order by studid" DA = New OleDb.OleDbDataAdapter(st, con) DA.Fill(ds, "student") xPath = Server.MapPath("student.xml") XSPath = Server.MapPath("Sch1.xsd") ds.WriteXml(xPath) ds.WriteXmlSchema(XSPath) Response.Write("<html> <br></html>") Response.Write("Inserted...") Response.Write("<html> <br></html>") con.Close()

Creating XML from a Database Table

• Showing Xml file

Response.Redirect("http://localhost/bsc/webapplication8/student.xml")

Creating Nested XML from a Dataset Objects

To use Nested Dataset using DataRelation Object – DataRelation Object is an ADO.Net object used with a

DataSet object to relate two Datatable objects together in a parent/child relationship.

– It represents the kind of relationship between tables that you might be familiar with from working with database, such as a one to many relationship.

– It is only the DataRelation object that has this information- the DataTable and DataColumn objects are distinct entities.

Creating Nested XML from a Dataset Objects

• Inserting in XML file from more than one TableDim con As New OleDb.OleDbConnection,DA As OleDb.OleDbDataAdapter,ds As New DataSet,Dim Dr As DataRelation con.ConnectionString = "Provider=SQLOLEDB.1;User ID=sa;Data Source=BSLS034;Initial Catalog=pubs" con.Open()

DA = New OleDb.OleDbDataAdapter("Select * from publishers;select * from titles", con) DA.Fill(ds) ds.Tables(0).TableName = "publishers" ds.Tables(1).TableName = "titles"Dr = New DataRelation("pubInfo", ds.Tables("publishers").Columns("pub_id"),

ds.Tables("titles").Columns("pub_id")) ds.Relations.Add(Dr) Dim xPath As String, XSPath As String xPath = Server.MapPath("pubDet.xml") XSPath = Server.MapPath("PubSch1.xsd") ds.WriteXml(xPath) ds.WriteXmlSchema(XSPath) Response.Write("<html> <br></html>") Response.Write("Inserted...")

Creating Nested XML from a Dataset Objects

Displaying XML file on to browser

Response.Redirect("http://localhost/bsc/webapplication8/pubDet.xml")

Reading Data into a Dataset from XML

• Populating Dataset tables with XML dataset is useful when an application is receiving data in XML form.

• We can also merge it with a database table or display it using Datagrid control. The method of the dataset objects that are used for Reading the XML file.

• Reading XML file Dim ds As New DataSet Dim xPath As String, XSPath As String

xPath = Server.MapPath("student.xml") XSPath = Server.MapPath("Sch1.xsd") ds.ReadXmlSchema(XSPath) ds.ReadXml(xPath) DataGrid1.DataSource = ds DataGrid1.DataBind()

Transform an XML document

• XML is clearly a rich meta language and using it is in intuitive and powerful .

• We easly transform XML into whatever format you need like HTML,XML,PDF,RTF and more.

• XSLT :

– Xslt (eXtensible Stylesheet Language Transformations) is a language used to transform one XML document into another.

– It has been increasable since 1999 when the 1.0 recommendation was finalized by the W3C .

XSLT Continue ..

• Functionality XSLT is the perform complement to XML, an XML document is defined by its semantic rich element but the structure of the information often needs to be altered for further use.

• XSLT is what enable XML to reach the full level of flexibility that it was born with.

XSLT transformation process

• The XSLT transformation process is quite simple

– An XSLT style sheet is written. This style sheet is itself a special kind of XML document.

– The style sheet is provided to an XSLT engine or parser. There are numerous implementation of the XSLT specification including the popular Saxon and MSXML parser as well as .Net engine.

– The style is applies to the XML document to be transform and the resulting file is output.

– The exact nature of the output is determined by the application of the style sheet to the XML and can include HTML XML plain text a schema another XSLT document RTF,PDF or other files.

XSLT transformation process

Input

XML Docs

XLT Stylesheet

XLT Stylesheet

XLT Stylesheet

XLT Stylesheet

XSLT Processor

Output

XML Doc 1

XML Doc 1

XLT Stylesheet

XML Schema

HTML Doc1

Text File etc.

Xsl transform object

• The xsl transform object is a net object that transform XML data using an XSLT stylesheet . It has two vital method used to accomplish this .– This object support the w3c xslt 1.0 syntax . The style sheet

therefore must include the declaration “xmlns: xsl= http//www.w3.org/1999/xsl/transform”

– This object support extend XSLT scripting using either VB C# or java script. Just as with the xslt implementation in the MSXML parser the <msxsl: script>element is used for this. This is an advanced topic and beyond the scope of this course but you can consult the .net SDK reference for details.

Load method:- The load method load the xslt stylesheet which can be supplied either from a disk file or from an xml reader or xpath navigator object. This will include any include or imported style sheet as necessary

Xsl transform object

Transform method :-The transform method transform the specified xml

data using the specified XSLT style sheet and output the result to either a disk file or an xml reader stream, xml writer, or text writer object . It takes three argument the xml data to be transformed the desired output destination and an optional list of style sheet parameter

How the xsl transform object works

• To accomplish the transformation once an xsl transform object is instantiated you really only need to do two thing . First you provide it with an XSLT stylesheet by using the load method and then you use it to transform the content by using the transform method.

XSLT Stylesheet

From a disk file, XmlReader, XPathNavigator

XSLT Stylesheet

From a disk file, XmlReader, XPathNavigator

XSLT Stylesheet

From a disk file, XmlReader, XPathNavigator

XSLT Stylesheet

From a disk file, XmlReader, XPathNavigator

XslTransform Object

Load Method

Transform Method

Transforming an XML Document into HTML

• Transforming into HTML

Dim xPath As String, XSLTPath As String, strOutPath As String

xPath = Server.MapPath("student.xml")

XSLTPath = Server.MapPath("student.xsl")

strOutPath = Server.MapPath("linktable.html")

Dim objTran As New XslTransform

objTran.Load(XSLTPath)

objTran.Transform(xPath, strOutPath)

Reading HTML fileResponse.Redirect("http://localhost/bsc/webapplication8/linktable.html")

Approach

CodeCode

Remote ServerRemote ServerCalling ClientCalling Client

ClientClient

XML/HTTPXML/HTTP

ProxyProxy StubStub

VS.NET createsVS.NET creates

Create ManuallyCreate Manually

• Manual approach allows custom handling of XML• Framework approach may not work in all cases but it’s fast

and easy

Creating Web Services

Steps• Choose the Project template as ASP .Net Web Services• Create the project with the path to Virtual Directory (default http://localhost/)• To add the functionality choose the code window

Following files are created for each XML Web Services• AssemblyInfo.cs

– Consists of general information about the assemblies in the project• Web.config

– Contains Configuration information• Authentication mode and debug mode for the project• Displaying custom errors for the project

• Global.asax & Global.asax.cs– To manage application level and session level events– Reside in the root directory of ASP .Net Web Application or Web Services

• Service1.asmx & Service1.asmx.cs– Above 2 files make up a single Web Services

• Service1.vsdisco– Contains links or URL to resources providing discovery information for an Web

Services

SOAP (Simple Object Access Protocol)

• Provides a Standard way of packaging Message

• It is not tightly coupled to one language.

– SOAP does not specify an API, so the implementation of the API is left up to the programming language (such as Java) and the platform (such as Microsoft .NET).

• It is not tightly coupled to a particular transport protocol

– SOAP message is nothing more than an XML document, so it can be transported over any protocol that is capable of transmitting text

SOAP (Simple Object Access Protocol)

• It leverages existing industry standards – SOAP leverages XML for encoding messages. – Instead of using its own type system, SOAP

leverages the type definitions already defined within the XML Schema specification

• It enables interoperability across multiple environments – A desktop application running on a PC can effectively

communicate with a back-end application running on a mainframe that is capable of sending and receiving XML over HTTP.

SOAP - Key Aspects

• SOAP envelope– Used to encode header information about the

message and the body of message itself

• SOAP encoding– A Standard way of serializing data into the body of a

SOAP message.

• HTTP POST protocol binding– Standard method of binding SOAP message to HTTP.

SOAP - Elements

• SOAP envelope (root element) contains – Header : It is optional element, that contains information

about the message – Body : It is mandatory element, that contains the message

<soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>

<soap:Header>

<!– Header is optional -- >

<from>Sender</from>

<to>receiver</to>

</soap:Header>

<soap:Body>

<!– Message is written here -- >

This is a sample demo for soap message

</soap:Body>

</soap:Envelope>

WSDL (Web Service Description Language)

• Root element is definitions

• types : Contains the schema definitions of the messages that can be sent and received by the service

• message : Serves as a cross-reference that associates the message with its definition within the schema.

• portType  : Defines a set of interfaces that the Web service can expose. An interface is associated with one or more messages

• binding  : Associates the portType definition with a particular protocol.

• service  : Defines a collection of related endpoints (ports) exposed by the Web service.

Consider the following functionality provided by a Web Service

public int Add(int num1,int num2) {

return num1 + num2;

}

WSDL – types element

<types> <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> <s:element name="Add">

<s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="num1" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="num2" type="s:int" /> </s:sequence></s:complexType>

</s:element>

<s:element name="AddResponse"><s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:int" /> </s:sequence></s:complexType>

</s:element></s:schema>

</types>

WSDL – message element

• provides a common abstraction for messages passed between the client and the server

• part is a child element– name

– element

<message name="AddSoapIn">

<part name="parameters" element="s0:Add" />

</message>

<message name="AddSoapOut">

<part name="parameters" element="s0:AddResponse" />

</message>

WSDL – portType element

• can be thought of as an interface definition in which each method can be defined as an operation.

• operation is a child element– Defines input , output and fault element.

<portType name="ValidateSoap">

- <operation name="Add">

  <input message="s0:AddSoapIn" />

  <output message="s0:AddSoapOut" />

</operation>

</portType>

WSDL – binding element

• contains binding definitions for binding a protocol such as SOAP to a particular bindingType

<binding name="ValidateSoap" type="s0:ValidateSoap">

  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

<operation name="Add">

  <soap:operation soapAction="http://tempuri.org/Add" style="document" />

<input>

  <soap:body use="literal" />

  </input>

<output>

  <soap:body use="literal" />

  </output>

  </operation>

 </binding>

WSDL – service element

• A service is a group of related ports and is defined by the service element

<service name="Validate">

- <port name="ValidateSoap" binding="s0:ValidateSoap">

<soap:address location="http://localhost/mywebapps/TestProject/Validate.asmx" />

  </port>

</service>

Consuming a Web Service

Steps• Add a Web reference to XML Web Service in the

client application• Generate a proxy class for XML Web Service• Create an object of XML Web Service proxy

class in the client application• Access the XML Web Service by using proxy

object

Communication Between Client and Web Services

Proxy

SOAPMessage

XML

SOAPMessage

XML

SOAPMessage

XML

SOAPMessage

XML

XML WebService Method

SOAP Request

SOAP Response

Network

Client Web Service

Deploying Web Services

• Web Services can be deployed in 2 ways

– Copy Web Service files to the Web Server

– Create a Web Setup project and deploy it

Items published with a Web Service

• Web Application Directory

– Root directory of Web Service

• WebService.asmx file

– Is the base URL for the clients to access the Web Service

• WebService.disco file

– Is an optional file that describes the discovery mechanism for Web Service

• Web.config file

– Is an optional file used to override the default configuration for Web Service

• \bin directory

– Contains binary files for Web Services

Code model for Web services

• A Web service is composed of two parts– Web service entry point – Code that provides the functionality to be used by other

applications. • The .asmx file serves as the entry point for the Web service. • The .asmx file accesses

– Code from precompiled assemblies – the code-behind (.cs) file corresponding to the Web service.

• Code-behind file – imports the System.Web.Services namespace, which contains

the classes that are required to build and use Web services.

Code model for Web services

• All Web service classes – Inherit the WebService class, which belongs to the

System.Web.Services namespace.• While writing code within the Web service class, you can

use the following attributes:– WebService: Used to provide additional information

about the Web methods exposed by a Web service. – WebMethod: Used for every method that needs to be

exposed for use by other applications

What does secure mean?

• Prevents inappropriate access by specifying requirements for:– Authentication– Authorization– Integrity– Confidentiality– Non-Repudiation

Web Service - Security

• Anonymous authentication

– No authentication takes place – mechanism that would be used for public data

• Basic authentication

– Username and Password are authenticated– Not commonly used as data is not encrypted

• Digest authentication

– Username and Password are authenticated– Data is encrypted – Is only supported by IE browser 5 and above

Web Service - Security

• Windows authentication

– Best suited for intranet• Certificate-based authentication

– Symmetric and Asymmetric Encryption • .NET Passport authentication

– centralized authentication service provided by Microsoft that offers a single sign-on and profile services for member sites

Existing Technologies

• Current Web Services use existing technologies– so “securing” a Web Service is similar to “securing” a

Web Site• Authentication

– Kerberos, LDAP, NTLM, Basic, etc.• Authorization

– Windows 2000 ACLs, .NET Declarative Security• Integrity

– SSL, IPSec, X.509• Confidentiality

– SSL, IPSec• Non-Repudiation

– X.509

Deploying Web Service

When you deploy an XML Web service, the following components of the Web service are published on the Web:

The Web application directory.

This component is the root directory for your XML Web service. All the XML Web service files are present in this directory or the subdirectories that you may create.

The <WebService>.asmx file.

This file is the base URL for the clients who access your XML Web service.

The <WebService>.disco file.

This is an optional file that describes the discovery mechanism for your XML Web service. You will learn more about the discovery mechanism in the next lesson.

The Web.config file.

This file is optional. You include it to override the default configuration settings of your XML Web service. You can use the configuration file to customize the system or store configuration information for your application.

The \Bin directory.

This directory contains binary files for the XML Web service. If you do not define your XML Web service class in the same file as the .asmx file, the assembly containing the class should be present in the \Bin directory.

Consuming Web Services

After you create an XML Web service and publish it, any application having permission to access the Web service can access your XML Web service and consume its services.

The application that consumes a Web service is known as the Web service client.

A Web service client can be a component, service, or desktop application.

In fact, the most common Web service clients that consume Web services are Web applications and Web services.

Consuming Web Services

To access an XML Web service from a client application, you need to perform the following tasks:

1. Add a Web reference to the XML Web service in the client application by discovering the XML Web service that you want to consume.

2. Generate a proxy class for the XML Web service.

3. Create an object of the XML Web service proxy class in the client application.

4. Access the XML Web service by using a proxy object.

Adding a Web Reference

To use the services of an XML Web service, you first locate the XML Web service using the discovery mechanism.

To use an XML Web service created by another programmer, you should know the location of the XML Web service and whether the Web service fulfills your requirement.

If you don't know where the service is, you can search for it via UDDI.

To make it easy to discover an XML Web service, Visual Studio .NET provides a Web reference for each XML Web service that you use in a project.

A Web reference is the local representation of an XML Web service in your project.

Advance Web Services Programming

XML Web services enable client applications to call Web methods using standard Internet protocols such as HTTP, XML, and SOAP.

A Web method is a method of an XML Web service that is decorated with the WebMethod attribute.

The WebMethod attribute has properties that you can use to modify the behavior of Web methods.

Web Services can also be configure for security.

Attributes of Web Method

You supply the WebMethod attribute to any method that you want to expose as a method of an XML Web service. The WebMethod attribute enables a client application to use standard Internet protocols to access the method.

The WebMethod attribute provides the following properties that enable you to customize and control the behavior of the methods that you expose in your Web service:

1. BufferResponse2. CacheDuration3. Description 4. EnableSession 5. MessageName

Buffer Web Method Response

public class Service1 : System.Web.Services.WebService{     [WebMethod (BufferResponse=false)]     public int AddNumbers(int num1, int num2)     {         return (num1+num2);     } }

Default Value = True

Buffer all Response before sending to the client

If value is false then ASP.NET buffer response in 16 KB chunks

Cashing Web Method Result

public class Service1 : System.Web.Services.WebService{

[WebMethod(CacheDuration=60)]     public int AddNumbers(int num1, int num2)     {         return (num1+num2);     } }

Defult Value = 0 sec

Web Method Description

public class Service1 : System.Web.Services.WebService{

[WebMethod(Description="Takes two integer values and returns " + "their sum.")]

    public int AddNumbers(int num1, int num2)     {         return (num1+num2);     } }

Enable Session Support

public class Service1 : System.Web.Services.WebService{    [WebMethod(EnableSession=true)]     public void setValue (int value)     {         Session[“Value"] = value;     }

    [WebMethod(EnableSession=true)]     public int getValue()     {         

return (int) Session[“Value"];     } }

Defult Value = false

Web Methods Overloading

public class Service1 : System.Web.Services.WebService{    [WebMethod(MessageName="AddIntegers")]     public int AddNumbers(int num1, int num2)     {         return (num1+num2);     }

    [WebMethod(MessageName="AddLongs")]     public long AddNumbers(long num1, long num2)     {         return (num1+num2);     }}

Web Services Security & Configuration

• Multiple configuration files can exist in various Web application folders on a Web server.

• Each Web.config file applies configuration settings to its own Web application folder and to all the child folders.

• The Web.config files in the child folders can contain configuration information that is in addition to the configuration information inherited from the parent folder.

• At run time, the CLR uses the configuration information in the Web.config files in a hierarchical structure to create a collection of configuration settings for each unique URL.

Web Services Security & Configuration

• The CLR can automatically detect changes made to Web.config files and apply the new settings to a Web service.

• In addition, hierarchical configuration settings are automatically recalculated again when you make modifications to a Web.config file in the hierarchy.

• The Web server prevents direct access to the Web.config file.

• The Web server returns the HTTP access error 403 to any browser that tries to request a configuration file directly.

Web Services Security & Configuration

<?xml version="1.0" encoding="utf-8" ?>

<configuration>     <system.web>         <compilation defaultLanguage="vb" debug="true" />         <customErrors mode="RemoteOnly" />         <authentication mode="Windows" />         <authorization>             <allow users="*" />          </authorization> </system.web> </configuration>

<Compilation />

You use this tag to specify the compilation language and whether you want to debug the Web service.

<CustomErrors />

You use this tag to manage custom error messages. You can set the mode attribute to

On to enable custom error messagesRemoteOnly to enable custom error messages for remote usersOff to disable error messages

<Authentication />

Windows Authentication

<authentication mode="Windows" />

Form Based Authentication

<authentication mode="Forms">     <forms forms="Sales" loginUrl="/login.aspx" /> </authentication>

Passport

<authentication mode="Passport" />

<authentication mode="None" />

<Authorization />

<authorization>     <deny users="Nancy"/>     <allow users=“James, Mark" /></authorization>

<authorization>     <allow users="Nancy" />     <deny users="*" /> </authorization>

<authorization><deny users=“Mark" /><allow users=“*" />

</authorization>

<authorization><deny users=“Mark" /><allow users=“*" />

</authorization>

Thank You