SlideShare una empresa de Scribd logo
1 de 21
XML Web Services
The term Web service is relatively new, but the idea behind Web services has been
around for a while. A Web service is an interface-less Web site designed for
programmatic access. This means that instead of invoking URLs representing Web
pages, you invoke URLs that represent methods on remote objects. Similarly, instead
of getting back colorful and animated HTML code, you get back XML Schema Definition
(XSD) data types packed in XML messages. Aside from these higher-level differences,
the underlying models for a Web site and a Web service are the same. In addition, any
security measure you can implement on a Web site can be duplicated in a Web service.
To summarize, the Web service model is just another programming model running on
top of HTTP.
A Web service is a software application that can be accessed over the Web by other
software. Web services are applicable in any type of Web environment, be it Internet,
intranet, or extranet. All you need to locate and access a Web service is a URL. In
theory, a number of Internet-friendly protocols might be working through that URL. In
practice, the protocol for everyday use of Web services is always HTTP.
How is a Web service different from a remote procedure call (RPC) implementation of
distributed interfaces? For the most part, a Web service is an RPC mechanism that
uses the Simple Object Access Protocol (SOAP) to support data interchange. This
general definition represents the gist of a Web service, but it focuses only on the core
behavior. A Web service is more than just a business object available over an HTTPaccessible
network. A number of evolving industry standards are supported today,
including the Universal Description, Discovery, and Integration (UDDI) standard and the
Web Services Description Language (WSDL); others, such as the Web Services
Security (WS-Security) and the Global XML Web Services Architecture (GXA), will be
supported soon. These industry standards contribute to setting up a full and powerful
environment for remote object-oriented access and programming
The .NET Framework Infrastructure for
Web Services
Although Web services and the .NET Framework were introduced at roughly the same
time, there is no strict dependency between the two, and the presence of one does not
necessarily imply the presence of the other. The .NET Framework is simply one of the
platforms that support Web services and that provide effective tools and system classes
to create and consume Web services. No one person invented Web services, but all the
big players in the IT arena are rapidly adopting and transforming the raw idea of
"software callable by other software" into something that fits their respective
development platforms.
The Simple Object Access Protocol
(SOAP)
SOAP is a simple, lightweight XML-based protocol for exchanging information on the
Web. SOAP defines a messaging framework that is independent from any application
or transportation protocol. Although, as mentioned, SOAP packets travel mostly as
HTTP-POST commands, SOAP neither mandates nor excludes any network and
transportation protocol
The most important part of the SOAP specification consists of an envelope for
encapsulating data. The SOAP envelope defines a one-way message and is the atomic
unit of exchange between SOAP senders and receivers. The SOAP specification also
needs a request/response message exchange pattern, although it does not mandate a
specific message pattern. The remaining, optional parts of the SOAP specification are
data encoding rules for representing application-defined data types and a binding
between SOAP and HTTP.
IIS Support
A .NET Framework Web service is a Microsoft ASP.NET application with an.asmx
extension that is accessed over HTTP. ASP.NET, as a whole, is part of the .NET
Framework that works on top of IIS, taking care of files with special extensions such as
.aspx and .asmx. One of the key components of the ASP.NET infrastructure is the
Internet Server Application Programming Interface (ISAPI) filter that IIS involves when it
gets a call for files with a certain extension.
The IIS mapping between .asmx files and the appropriate ASP.NET ISAPI
filter.
The connection between the IIS process (the executable named inetinfo.exe) and the
HTTP pipeline (the worker executable named aspnet_wp.exe) is established through a
named pipe—that is, a Win32 mechanism for transferring data over a network. As you'd
expect, a named pipe works just like a pipe: you enter data in one end, and the same
data comes out at the other end. Pipes can be established both locally to connect
processes and between remote machines.
After the ASP.NET worker process receives a request, it routes that request through
the .NET Framework HTTP pipeline. The entry point of the pipeline is the HttpRuntime
class. This class is responsible for packaging the HTTP context for the request, which
is nothing more than familiar Active Server Pages (ASP) objects such as Request,
Response, Server, and the like. These objects are packed into an instance of the
HttpContext class, and then a .NET Framework application is started.
The WebService Class
In the .NET Framework, a Web service is an ordinary class with public and protected
methods. The Web service class is normally placed in a source file that is saved with an
.asmx extension. Web service files must contain the @ WebService directive that
informs the ASP.NET run time about the nature of the file, the language in use
throughout, and the main class that implements the service, as shown here:
<%@ WebService Language="C#" Class="MyWebServiceClass" %>
The Language attribute can be set to C#, VB, or JS. The main class must match the
name declared in the Class attribute and must be public, as shown here:
The WebService Attribute
The WebService attribute is optional and does not affect the activity of the Web service
class in terms of what is published and executed. The WebService attribute is
represented by an instance of the WebServiceAttribute class and enables you to
change three default settings for the Web service: the namespace, the name, and the
description.
Building a .NET Web Service
As mentioned, a Web service is a class that optionally inherits from WebService. As
such, the class can implement any number of interfaces and, as long as you don't need
to directly access common ASP.NET objects, can also inherit from any other .NET
Framework or user-defined class. The definition of the class must necessarily be coded
in an .asmx file. The file is made available to potential clients through a Web server
virtual directory and is accessed through a URL. Any client that can issue HTTP
commands can connect to the Web service unless security settings restrict the client's
access to the service.
What happens after a client points to the URL is the focus of the rest of this chapter.
Let's start by analyzing the internal structure of the Web service class.
Format of SOAP Messages for a Web Method
Although SOAP dictates that the messages being exchanged between the Web service
and its clients must be in XML, it says nothing about the actual schema of the XML. The
.NET Framework provides an attribute-based mechanism to let you control the format
of the XML packed in the SOAP message. To customize the structure of a SOAP
message, you can intervene in two places: you can modify the layout of the information
being packed beneath the <soap:
Processing a Web service call
Building a .NET Framework Web Service Client
Whether you use Microsoft Visual Studio .NET or a simple text editor to code the .asmx
file, writing Web services using the .NET Framework is definitely an easy task. And as
you'll see, writing client applications to use those services is even easier.
You can call a Web service through a URL using either the HTTP-GET or the HTTPPOST
command. You can do that also from within an ASP.NET page using the
WebRequest .NET Framework class. From within Visual Studio .NET, referencing a
Web service is nearly identical to adding a reference to another assembly. What you
get is a proxy class through which your Windows Forms or Web Forms application can
reach its URL across port 80, just like a user's browser. In doing so, firewall problems
disappear and HTTP on top of Secure Sockets Layer (SSL) or any other form of
encryption can be used to transfer data.
A Windows Forms Web service client in
action.
Invoking a Web Service Through Script
A Web service is always invoked by using an ordinary HTTP packet that contains
information about the method to call and the arguments to use. This HTTP packet
reaches the Web server by traveling as a GET or POST command. You can invoke a
Web service method using one of these commands:
.. A POST command that embeds a SOAP request
.. A POST command that specifies the method name and parameters
.. A GET command whose URL contains the method name and parameters
To invoke a method in a Web service, SOAP is not strictly necessary. You can use
GET or POST commands, which results in a more compact body. However, the
benefits of using SOAP become clearer as the complexity of data increases. GET and
POST commands support primitive types, including arrays and enumerations. SOAP,
on the other hand, relies on a portable and more complex type system based on XML
schemas. In addition, in the .NET Framework, Web services also support classes that
the XML serializer can handle.
A Windows Script Host Example
To give you a practical demonstration of how Web services are really just HTTPaccessible
software agents, let's write a Windows Script Host (WSH) script that allows
plain Microsoft Visual Basic, Scripting Edition (VBScript) code to download information
from a remote server. To send HTTP commands from VBScript code, we'll use the
Microsoft.XmlHttp object—a native component of Microsoft Internet Explorer 5.0 and
MSXML 3.0 and later versions. The following script calls the method GetSalesReport by
using a GET command:
Xml web services

Más contenido relacionado

La actualidad más candente

JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 

La actualidad más candente (20)

Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
Html forms
Html formsHtml forms
Html forms
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
CSS
CSSCSS
CSS
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
 
Java swing
Java swingJava swing
Java swing
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 

Similar a Xml web services

Web services
Web servicesWeb services
Web services
aspnet123
 
webservices overview
webservices overviewwebservices overview
webservices overview
elliando dias
 
Beginning with wcf service
Beginning with wcf serviceBeginning with wcf service
Beginning with wcf service
Binu Bhasuran
 

Similar a Xml web services (20)

Web services
Web servicesWeb services
Web services
 
Web Programming
Web ProgrammingWeb Programming
Web Programming
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
Java web services
Java web servicesJava web services
Java web services
 
Web programming
Web programmingWeb programming
Web programming
 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservices
 
Moving from webservices to wcf services
Moving from webservices to wcf servicesMoving from webservices to wcf services
Moving from webservices to wcf services
 
ASP.NET Unit-4.pdf
ASP.NET Unit-4.pdfASP.NET Unit-4.pdf
ASP.NET Unit-4.pdf
 
Dot net training-navimumbai
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbai
 
dotNETfinal.ppt
dotNETfinal.pptdotNETfinal.ppt
dotNETfinal.ppt
 
dotNETfinal.ppt
dotNETfinal.pptdotNETfinal.ppt
dotNETfinal.ppt
 
Top 10 - ASP.NET Interview Questions And Answers 2023.pdf
Top 10 -  ASP.NET Interview Questions And Answers 2023.pdfTop 10 -  ASP.NET Interview Questions And Answers 2023.pdf
Top 10 - ASP.NET Interview Questions And Answers 2023.pdf
 
Asp.netrole
Asp.netroleAsp.netrole
Asp.netrole
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
webservices overview
webservices overviewwebservices overview
webservices overview
 
Web API or WCF - An Architectural Comparison
Web API or WCF - An Architectural ComparisonWeb API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
 
Beginning with wcf service
Beginning with wcf serviceBeginning with wcf service
Beginning with wcf service
 
Soap Vs Rest
Soap Vs RestSoap Vs Rest
Soap Vs Rest
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Web services
Web servicesWeb services
Web services
 

Más de Raghu nath

Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
Raghu nath
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
Raghu nath
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raghu nath
 
Selection sort
Selection sortSelection sort
Selection sort
Raghu nath
 
Binary search
Binary search Binary search
Binary search
Raghu nath
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
Raghu nath
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
Raghu nath
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
Raghu nath
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
Raghu nath
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
Raghu nath
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
Raghu nath
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
Raghu nath
 

Más de Raghu nath (20)

Mongo db
Mongo dbMongo db
Mongo db
 
Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
 
MS WORD 2013
MS WORD 2013MS WORD 2013
MS WORD 2013
 
Msword
MswordMsword
Msword
 
Ms word
Ms wordMs word
Ms word
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Selection sort
Selection sortSelection sort
Selection sort
 
Binary search
Binary search Binary search
Binary search
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
 
Perl
PerlPerl
Perl
 

Último

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Xml web services

  • 2. The term Web service is relatively new, but the idea behind Web services has been around for a while. A Web service is an interface-less Web site designed for programmatic access. This means that instead of invoking URLs representing Web pages, you invoke URLs that represent methods on remote objects. Similarly, instead of getting back colorful and animated HTML code, you get back XML Schema Definition (XSD) data types packed in XML messages. Aside from these higher-level differences, the underlying models for a Web site and a Web service are the same. In addition, any security measure you can implement on a Web site can be duplicated in a Web service. To summarize, the Web service model is just another programming model running on top of HTTP.
  • 3. A Web service is a software application that can be accessed over the Web by other software. Web services are applicable in any type of Web environment, be it Internet, intranet, or extranet. All you need to locate and access a Web service is a URL. In theory, a number of Internet-friendly protocols might be working through that URL. In practice, the protocol for everyday use of Web services is always HTTP.
  • 4. How is a Web service different from a remote procedure call (RPC) implementation of distributed interfaces? For the most part, a Web service is an RPC mechanism that uses the Simple Object Access Protocol (SOAP) to support data interchange. This general definition represents the gist of a Web service, but it focuses only on the core behavior. A Web service is more than just a business object available over an HTTPaccessible network. A number of evolving industry standards are supported today, including the Universal Description, Discovery, and Integration (UDDI) standard and the Web Services Description Language (WSDL); others, such as the Web Services Security (WS-Security) and the Global XML Web Services Architecture (GXA), will be supported soon. These industry standards contribute to setting up a full and powerful environment for remote object-oriented access and programming
  • 5. The .NET Framework Infrastructure for Web Services Although Web services and the .NET Framework were introduced at roughly the same time, there is no strict dependency between the two, and the presence of one does not necessarily imply the presence of the other. The .NET Framework is simply one of the platforms that support Web services and that provide effective tools and system classes to create and consume Web services. No one person invented Web services, but all the big players in the IT arena are rapidly adopting and transforming the raw idea of "software callable by other software" into something that fits their respective development platforms.
  • 6. The Simple Object Access Protocol (SOAP) SOAP is a simple, lightweight XML-based protocol for exchanging information on the Web. SOAP defines a messaging framework that is independent from any application or transportation protocol. Although, as mentioned, SOAP packets travel mostly as HTTP-POST commands, SOAP neither mandates nor excludes any network and transportation protocol
  • 7. The most important part of the SOAP specification consists of an envelope for encapsulating data. The SOAP envelope defines a one-way message and is the atomic unit of exchange between SOAP senders and receivers. The SOAP specification also needs a request/response message exchange pattern, although it does not mandate a specific message pattern. The remaining, optional parts of the SOAP specification are data encoding rules for representing application-defined data types and a binding between SOAP and HTTP.
  • 8. IIS Support A .NET Framework Web service is a Microsoft ASP.NET application with an.asmx extension that is accessed over HTTP. ASP.NET, as a whole, is part of the .NET Framework that works on top of IIS, taking care of files with special extensions such as .aspx and .asmx. One of the key components of the ASP.NET infrastructure is the Internet Server Application Programming Interface (ISAPI) filter that IIS involves when it gets a call for files with a certain extension.
  • 9. The IIS mapping between .asmx files and the appropriate ASP.NET ISAPI filter.
  • 10.
  • 11. The connection between the IIS process (the executable named inetinfo.exe) and the HTTP pipeline (the worker executable named aspnet_wp.exe) is established through a named pipe—that is, a Win32 mechanism for transferring data over a network. As you'd expect, a named pipe works just like a pipe: you enter data in one end, and the same data comes out at the other end. Pipes can be established both locally to connect processes and between remote machines. After the ASP.NET worker process receives a request, it routes that request through the .NET Framework HTTP pipeline. The entry point of the pipeline is the HttpRuntime class. This class is responsible for packaging the HTTP context for the request, which is nothing more than familiar Active Server Pages (ASP) objects such as Request, Response, Server, and the like. These objects are packed into an instance of the HttpContext class, and then a .NET Framework application is started.
  • 12. The WebService Class In the .NET Framework, a Web service is an ordinary class with public and protected methods. The Web service class is normally placed in a source file that is saved with an .asmx extension. Web service files must contain the @ WebService directive that informs the ASP.NET run time about the nature of the file, the language in use throughout, and the main class that implements the service, as shown here: <%@ WebService Language="C#" Class="MyWebServiceClass" %> The Language attribute can be set to C#, VB, or JS. The main class must match the name declared in the Class attribute and must be public, as shown here:
  • 13. The WebService Attribute The WebService attribute is optional and does not affect the activity of the Web service class in terms of what is published and executed. The WebService attribute is represented by an instance of the WebServiceAttribute class and enables you to change three default settings for the Web service: the namespace, the name, and the description.
  • 14. Building a .NET Web Service As mentioned, a Web service is a class that optionally inherits from WebService. As such, the class can implement any number of interfaces and, as long as you don't need to directly access common ASP.NET objects, can also inherit from any other .NET Framework or user-defined class. The definition of the class must necessarily be coded in an .asmx file. The file is made available to potential clients through a Web server virtual directory and is accessed through a URL. Any client that can issue HTTP commands can connect to the Web service unless security settings restrict the client's access to the service. What happens after a client points to the URL is the focus of the rest of this chapter. Let's start by analyzing the internal structure of the Web service class.
  • 15. Format of SOAP Messages for a Web Method Although SOAP dictates that the messages being exchanged between the Web service and its clients must be in XML, it says nothing about the actual schema of the XML. The .NET Framework provides an attribute-based mechanism to let you control the format of the XML packed in the SOAP message. To customize the structure of a SOAP message, you can intervene in two places: you can modify the layout of the information being packed beneath the <soap:
  • 16. Processing a Web service call
  • 17. Building a .NET Framework Web Service Client Whether you use Microsoft Visual Studio .NET or a simple text editor to code the .asmx file, writing Web services using the .NET Framework is definitely an easy task. And as you'll see, writing client applications to use those services is even easier. You can call a Web service through a URL using either the HTTP-GET or the HTTPPOST command. You can do that also from within an ASP.NET page using the WebRequest .NET Framework class. From within Visual Studio .NET, referencing a Web service is nearly identical to adding a reference to another assembly. What you get is a proxy class through which your Windows Forms or Web Forms application can reach its URL across port 80, just like a user's browser. In doing so, firewall problems disappear and HTTP on top of Secure Sockets Layer (SSL) or any other form of encryption can be used to transfer data.
  • 18. A Windows Forms Web service client in action.
  • 19. Invoking a Web Service Through Script A Web service is always invoked by using an ordinary HTTP packet that contains information about the method to call and the arguments to use. This HTTP packet reaches the Web server by traveling as a GET or POST command. You can invoke a Web service method using one of these commands: .. A POST command that embeds a SOAP request .. A POST command that specifies the method name and parameters .. A GET command whose URL contains the method name and parameters To invoke a method in a Web service, SOAP is not strictly necessary. You can use GET or POST commands, which results in a more compact body. However, the benefits of using SOAP become clearer as the complexity of data increases. GET and POST commands support primitive types, including arrays and enumerations. SOAP, on the other hand, relies on a portable and more complex type system based on XML schemas. In addition, in the .NET Framework, Web services also support classes that the XML serializer can handle.
  • 20. A Windows Script Host Example To give you a practical demonstration of how Web services are really just HTTPaccessible software agents, let's write a Windows Script Host (WSH) script that allows plain Microsoft Visual Basic, Scripting Edition (VBScript) code to download information from a remote server. To send HTTP commands from VBScript code, we'll use the Microsoft.XmlHttp object—a native component of Microsoft Internet Explorer 5.0 and MSXML 3.0 and later versions. The following script calls the method GetSalesReport by using a GET command: