Xml web services

Raghu nath
Raghu nathSr.Analyst at Textual Analytics Solutions Pvt ltd,A FOSS(Free and open-source software) enthusiast
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.
Xml web services
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
1 de 21

Recomendados

Introduction to Visual Studio.NET por
Introduction to Visual Studio.NETIntroduction to Visual Studio.NET
Introduction to Visual Studio.NETDutch Dasanaike {LION}
3.3K vistas41 diapositivas
Java web services por
Java web servicesJava web services
Java web serviceskumar gaurav
2.7K vistas33 diapositivas
Asp.net por
Asp.netAsp.net
Asp.netOpenSource Technologies Pvt. Ltd.
1.9K vistas21 diapositivas
Bootstrap por
BootstrapBootstrap
BootstrapJohn Pereless
654 vistas9 diapositivas
Rich Internet Applications por
Rich Internet ApplicationsRich Internet Applications
Rich Internet ApplicationsYoussef Shaath
6.3K vistas41 diapositivas
Front-End Frameworks: a quick overview por
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewDiacode
15.1K vistas27 diapositivas

Más contenido relacionado

La actualidad más candente

Web Servers (ppt) por
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)webhostingguy
65.7K vistas30 diapositivas
Ajax ppt por
Ajax pptAjax ppt
Ajax pptOECLIB Odisha Electronics Control Library
9.1K vistas17 diapositivas
Introduction to jQuery por
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
1.6K vistas41 diapositivas
Front-end technologies for Wonderful User Experience through Websites por
Front-end technologies for Wonderful User Experience through WebsitesFront-end technologies for Wonderful User Experience through Websites
Front-end technologies for Wonderful User Experience through WebsitesReady Bytes Software labs
1.1K vistas17 diapositivas
Asp net por
Asp netAsp net
Asp netDr. C.V. Suresh Babu
1.2K vistas31 diapositivas
Netbeans IDE & Platform por
Netbeans IDE & PlatformNetbeans IDE & Platform
Netbeans IDE & PlatformAatul Palandurkar
5.6K vistas28 diapositivas

La actualidad más candente(20)

Web Servers (ppt) por webhostingguy
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
webhostingguy65.7K vistas
Introduction to jQuery por Zeeshan Khan
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Zeeshan Khan1.6K vistas
Front-end technologies for Wonderful User Experience through Websites por Ready Bytes Software labs
Front-end technologies for Wonderful User Experience through WebsitesFront-end technologies for Wonderful User Experience through Websites
Front-end technologies for Wonderful User Experience through Websites
Html5 tutorial for beginners por Singsys Pte Ltd
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
Singsys Pte Ltd16.3K vistas
Java Web Services [1/5]: Introduction to Web Services por IMC Institute
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
IMC Institute3.5K vistas
What is Material UI? por Flatlogic
What is Material UI?What is Material UI?
What is Material UI?
Flatlogic1.4K vistas
Asp .net web form fundamentals por Gopal Ji Singh
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentals
Gopal Ji Singh5K vistas
Implement text editor por Amaan Shaikh
Implement text editorImplement text editor
Implement text editor
Amaan Shaikh5.1K vistas

Similar a Xml web services

Web services por
Web servicesWeb services
Web servicesaspnet123
452 vistas28 diapositivas
Web Programming por
Web ProgrammingWeb Programming
Web ProgrammingVijayapriyaP1
55 vistas36 diapositivas
Understanding Web Services by software outsourcing company india por
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaJignesh Aakoliya
177 vistas22 diapositivas
Web programming por
Web programmingWeb programming
Web programmingsowfi
45 vistas28 diapositivas
Introduction to webservices por
Introduction to webservicesIntroduction to webservices
Introduction to webservicesGagandeep Singh
2K vistas24 diapositivas
Moving from webservices to wcf services por
Moving from webservices to wcf servicesMoving from webservices to wcf services
Moving from webservices to wcf servicesBinu Bhasuran
1.4K vistas46 diapositivas

Similar a Xml web services(20)

Web services por aspnet123
Web servicesWeb services
Web services
aspnet123452 vistas
Understanding Web Services by software outsourcing company india por Jignesh Aakoliya
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
Jignesh Aakoliya177 vistas
Web programming por sowfi
Web programmingWeb programming
Web programming
sowfi45 vistas
Moving from webservices to wcf services por Binu Bhasuran
Moving from webservices to wcf servicesMoving from webservices to wcf services
Moving from webservices to wcf services
Binu Bhasuran1.4K vistas
ASP.NET Unit-4.pdf por abiraman7
ASP.NET Unit-4.pdfASP.NET Unit-4.pdf
ASP.NET Unit-4.pdf
abiraman734 vistas
Dot net training-navimumbai por vibrantuser
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbai
vibrantuser114 vistas
WebService-Java por halwal
WebService-JavaWebService-Java
WebService-Java
halwal3.4K vistas
webservices overview por elliando dias
webservices overviewwebservices overview
webservices overview
elliando dias1.4K vistas
Web API or WCF - An Architectural Comparison por Adnan Masood
Web API or WCF - An Architectural ComparisonWeb API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
Adnan Masood56.8K vistas
Beginning with wcf service por Binu Bhasuran
Beginning with wcf serviceBeginning with wcf service
Beginning with wcf service
Binu Bhasuran1.8K vistas
Soap Vs Rest por sreekveturi
Soap Vs RestSoap Vs Rest
Soap Vs Rest
sreekveturi1.3K vistas
Web services por ishmecse13
Web servicesWeb services
Web services
ishmecse13509 vistas
Bt0078 website design 2 por Techglyphs
Bt0078 website design 2Bt0078 website design 2
Bt0078 website design 2
Techglyphs38 vistas

Más de Raghu nath

Mongo db por
Mongo dbMongo db
Mongo dbRaghu nath
870 vistas25 diapositivas
Ftp (file transfer protocol) por
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)Raghu nath
2K vistas18 diapositivas
MS WORD 2013 por
MS WORD 2013MS WORD 2013
MS WORD 2013Raghu nath
3K vistas24 diapositivas
Msword por
MswordMsword
MswordRaghu nath
408 vistas3 diapositivas
Ms word por
Ms wordMs word
Ms wordRaghu nath
335 vistas5 diapositivas
Javascript part1 por
Javascript part1Javascript part1
Javascript part1Raghu nath
443 vistas14 diapositivas

Más de Raghu nath(20)

Ftp (file transfer protocol) por Raghu nath
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
Raghu nath2K vistas
Javascript part1 por Raghu nath
Javascript part1Javascript part1
Javascript part1
Raghu nath443 vistas
Regular expressions por Raghu nath
Regular expressionsRegular expressions
Regular expressions
Raghu nath505 vistas
Selection sort por Raghu nath
Selection sortSelection sort
Selection sort
Raghu nath248 vistas
Binary search por Raghu nath
Binary search Binary search
Binary search
Raghu nath2.9K vistas
JSON(JavaScript Object Notation) por Raghu nath
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath1.3K vistas
Stemming algorithms por Raghu nath
Stemming algorithmsStemming algorithms
Stemming algorithms
Raghu nath1.3K vistas
Step by step guide to install dhcp role por Raghu nath
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
Raghu nath317 vistas
Network essentials chapter 4 por Raghu nath
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
Raghu nath829 vistas
Network essentials chapter 3 por Raghu nath
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
Raghu nath1.1K vistas
Network essentials chapter 2 por Raghu nath
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
Raghu nath528 vistas
Network essentials - chapter 1 por Raghu nath
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
Raghu nath818 vistas
Python chapter 2 por Raghu nath
Python chapter 2Python chapter 2
Python chapter 2
Raghu nath728 vistas
python chapter 1 por Raghu nath
python chapter 1python chapter 1
python chapter 1
Raghu nath741 vistas
Linux Shell Scripting por Raghu nath
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
Raghu nath648 vistas

Último

Meet the Bible por
Meet the BibleMeet the Bible
Meet the BibleSteve Thomason
83 vistas80 diapositivas
Berry country.pdf por
Berry country.pdfBerry country.pdf
Berry country.pdfMariaKenney3
82 vistas12 diapositivas
A Guide to Applying for the Wells Mountain Initiative Scholarship 2023 por
A Guide to Applying for the Wells Mountain Initiative Scholarship 2023A Guide to Applying for the Wells Mountain Initiative Scholarship 2023
A Guide to Applying for the Wells Mountain Initiative Scholarship 2023Excellence Foundation for South Sudan
89 vistas26 diapositivas
11.30.23A Poverty and Inequality in America.pptx por
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptxmary850239
228 vistas18 diapositivas
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating... por
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...Taste
39 vistas34 diapositivas
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf por
 Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdfTechSoup
67 vistas28 diapositivas

Último(20)

11.30.23A Poverty and Inequality in America.pptx por mary850239
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptx
mary850239228 vistas
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating... por Taste
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...
Taste39 vistas
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf por TechSoup
 Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf
TechSoup 67 vistas
Peripheral artery diseases by Dr. Garvit.pptx por garvitnanecha
Peripheral artery diseases by Dr. Garvit.pptxPeripheral artery diseases by Dr. Garvit.pptx
Peripheral artery diseases by Dr. Garvit.pptx
garvitnanecha135 vistas
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE... por Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption... por BC Chew
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...
BC Chew40 vistas
Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab... por RAHUL PAL
Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab...Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab...
Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab...
RAHUL PAL45 vistas
JRN 362 - Lecture Twenty-Three (Epilogue) por Rich Hanley
JRN 362 - Lecture Twenty-Three (Epilogue)JRN 362 - Lecture Twenty-Three (Epilogue)
JRN 362 - Lecture Twenty-Three (Epilogue)
Rich Hanley44 vistas
11.21.23 Economic Precarity and Global Economic Forces.pptx por mary850239
11.21.23 Economic Precarity and Global Economic Forces.pptx11.21.23 Economic Precarity and Global Economic Forces.pptx
11.21.23 Economic Precarity and Global Economic Forces.pptx
mary85023994 vistas
What is Digital Transformation? por Mark Brown
What is Digital Transformation?What is Digital Transformation?
What is Digital Transformation?
Mark Brown46 vistas
GSoC 2024 .pdf por ShabNaz2
GSoC 2024 .pdfGSoC 2024 .pdf
GSoC 2024 .pdf
ShabNaz245 vistas

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.
  • 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: