You are on page 1of 18

www.1000projects.

com
www.fullinterview.com
www.chetanasprojects.com

XML WEB SERVICES
Contents
1. Intoduction to Web Services
2. XML Web Services verview
!. XML Web services Infrastructure
". XML Web Services #irectories
$. XML Web Service #iscover%&
'. XML Web Service #escription
(. XML Web Service Wire )ormats
*. S+, -Simple object access protocol.
/. 0reatin1 XML web service usin1 visual 02.net
10.Web Server
11.+ccessin1 an XML Web Service 3sin1 4isual 02.net
12.0onclusion
1!. 5eferences
1. Introduction to Web Services
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
Web services let applications share data6 and7more powerfull%7invo8e capabilities
from other applications without re1ard to how those applications were built6 what
operatin1 s%stem or platform the% run on6 and what devices are used to access them.
+lthou1h Web services remain independent of each other6 the% can loosel% lin8
themselves into a collaboratin1 1roup that performs a particular tas8.
9roadl% spea8in16 a Web Service is simpl% an application delivered as a service that can
be inte1rated with other Web Services usin1 Internet standards. In other words6 it:s a
35L;addressable resource that pro1rammaticall% returns information to clients who want
to use it. ne important feature of Web Services is that clients don:t need to 8now how a
service is implemented.
Li8e components6 Web Services represent blac8;bo< functionalit% that can be reused
without worr%in1 about how the service is implemented. Web Services provide well;
defined interfaces6 called contracts6 that describe the services provided. #evelopers can
assemble applications usin1 a combination of remote services6 local services6 and custom
code. )or e<ample6 a compan% mi1ht assemble an online store usin1 the Microsoft
,assport service to authenticate users6 a third;part% personali=ation service to adapt Web
pa1es to each user:s preferences6 a credit;card processin1 service6 a sales ta< service6
pac8a1e;trac8in1 services from each shippin1 compan%6 an in;house catalo1 service that
connects to the compan%:s internal inventor% mana1ement applications6 and a bit of
custom code to ma8e sure that their store stands out from the crowd.
)i1ure shows a model that illustrates how Web Services can be lin8ed to create
distributed Web applications.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
Web services are invo8ed over the Internet b% means of industr%;standard protocols
includin1 S+,> XML> and 3niversal #escription6 #iscover%6 and Inte1ration -3##I..
?he% are defined throu1h public standards or1ani=ations such as the World Wide Web
0onsortium -W!0..
?echnicall% a Web Service is ma8in1 a remote method call -5,0. where underl%in1
transport is @??, -internet..
?he methods are defined in WS#L usin1 XML6 and the messa1e is transported over
@??, in XML too usin1 S+, protocol.
?he implementer implements web service usin1 technolo1% such as
.AB? or Cava publishes its interface -WS#L. in 3##I -I9M6 Microsoft.6
?he user discovers web service -WS#L.6 and ma8es a call to the appropriate
MethodDfunction.
XML Web Services Overview
+n XML Web service is a pro1rammable entit% that provides a particular element of
functionalit%6 such as application lo1ic6 and is accessible to an% number of potentiall%
disparate s%stems usin1 ubiEuitous Internet standards6 such as XML and @??,. XML
Web services depend heavil% upon the broad acceptance of XML and other Internet
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
standards to create an infrastructure that supports application interoperabilit% at a level
that solves man% of the problems that previousl% hindered such attempts.
+n XML Web service can be used either internall% b% a sin1le application or e<posed
e<ternall% over the Internet for use b% an% number of applications. 9ecause it is
accessible throu1h a standard interface6 an XML Web service allows hetero1eneous
s%stems to wor8 to1ether as a sin1le web of computation.
Instead of pursuin1 the 1eneric capabilities of code portabilit%6 XML Web services
provide a viable solution for enablin1 data and s%stem interoperabilit%. XML Web
services use XML;based messa1in1 as a fundamental means of data communication to
help brid1e the differences that e<ist between s%stems that use incon1ruent component
models6 operatin1 s%stems6 and pro1rammin1 lan1ua1es. #evelopers can create
applications that weave to1ether XML Web services from a variet% of sources in much
the same wa% that developers traditionall% use components when creatin1 a distributed
application.
ne of the core characteristics of an XML Web service is the hi1h de1ree of abstraction
that e<ists between the implementation and consumption of a service. 9% usin1 XML;
based messa1in1 as the mechanism b% which the service is created and accessed6 both the
XML Web service client and the XML Web service provider are freed from needin1 an%
8nowled1e of each other be%ond inputs6 outputs and location.
.
XML Web services Infrastructure
ne of the primar% advanta1es of the XML Web services architecture is that it allows
pro1rams written in different lan1ua1es on different platforms to communicate with each
other in a standards;based wa%.
XML Web services enable the e<chan1e of data and the remote invocation of application
lo1ic usin1 XML messa1in1 to move data throu1h firewalls and between hetero1eneous
s%stems. +lthou1h remote access of data and application lo1ic is not a new concept6
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
doin1 so in a loosel% coupled fashion is. ?he onl% assumption between the XML Web
service client and the XML Web service is that recipients will understand the messa1es
the% receive. +s a result6 pro1rams written in an% lan1ua1e6 usin1 an% component model6
and runnin1 on an% operatin1 s%stem can access XML Web services.
XML Web services must be a1nostic re1ardin1 the choice of operatin1 s%stem6 object
model and pro1rammin1 lan1ua1e to succeed in the hetero1eneit% of the Web. +lso6 for
XML Web services to enjo% the same widespread adoption as other Web;based
technolo1ies6 the% must be&
Loosel% 0oupled& ?wo s%stems are considered loosel% coupled if the onl% mandate
imposed on both s%stems is to understand the aforementioned self;describin16 te<t;based
messa1es. ?i1htl% coupled s%stems6 on the other hand6 impose a si1nificant amount of
customi=ed overhead to enable communication and reEuire a 1reater understandin1
between the s%stems.
Ubiuitous Co!!unication& It is unli8el% an%one will build an operatin1 s%stem
now or in the near future that will not incorporate the abilit% to connect to the
Internet6 therefore providin1 a ubiEuitous communication channel. +s such6 the
abilit% to connect almost an% s%stem or device to the Internet will ensure such
s%stems and devices are universall% available to an% other s%stem or device
connected to the Internet.
Universa" #ata $or!at& 9% adoptin1 e<istin16 open standards over proprietar%6
closed;loop communication methods6 an% s%stem supportin1 the same open
standards is capable of understandin1 XML Web services. 3tili=in1 self;
describin16 te<t;based messa1es that XML Web services and their clients can
share without the need to 8now what constitutes each underl%in1 s%stems enables
communication between autonomous and disparate s%stems. XML Web services
achieve this capabilit% usin1 XML.
XML Web services emplo% an infrastructure that provides the followin1& a discover%
mechanism to locate XML Web services6 a service description for definin1 how to use
those services6 and standard wire formats with which to communicate.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
Infrastructure %iece Ro"e
XML Web Services
#irectories
XML Web services directories provide a central location to
locate XML Web services provided b% other or1ani=ations.
XML Web services directories such as a 3##I re1istr%
fulfill this role. XML Web service clients ma% or ma% not
need to reference an XML Web service:s director%.
XML Web Service
#iscover%
XML Web service discover% is the process of locatin16 or
discoverin16 one or more related documents that describe a
particular XML Web service usin1 the Web Services
#escription Lan1ua1e -WS#L.. ?he #IS0 specification
defines an al1orithm for locatin1 service descriptions. If
XML Web service clients 8now the location of the service
description6 the% can b%pass the discover% process.
XML Web Service
#escription
?o understand how to interact with a particular XML Web
service6 it is necessar% to provide a service description that
defines what interactions the XML Web service supports.
XML Web service clients must 8now how to interact with
an XML Web service before the% can use it.
XML Web Service Wire
)ormats
?o enable universal communication6 XML Web services
communicate usin1 open wire formats6 which are protocols
understandable b% an% s%stem capable of supportin1 the
most common Web standards. S+, is the 8e% protocol for
XML Web service communication.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
X!" Web Service Infrastructure 1
XML Web Services #irectories
Li8e an% other resource on the Internet6 it would be virtuall% impossible to find a
particular XML Web service without some means b% which to search for it. XML Web
services directories provide central locations where XML Web service providers can
publish information about their available XML Web services. Such directories ma% even
be XML Web services themselves6 accessible pro1rammaticall% and providin1 search
results in response to Eueries from potential XML Web service clients. It ma% be
necessar% to use an XML Web services director% to locate an or1ani=ation that provides
an XML Web service for a particular purpose6 or to determine what XML Web services a
particular or1ani=ation provides.
?he 3##I -3niversal #escription6 #iscover% and Inte1ration. specifications define a
standard wa% to publish and discover information about XML Web services. ?he XML
schemas associated with 3##I define four t%pes of information that would enable a
developer to use a published XML Web service. ?hese are& business information6 service
information6 bindin1 information6 and information about specifications for services.
+s a core component of the 3##I project6 the 3##I 9usiness 5e1istr% allows
businesses to pro1rammaticall% locate information about XML Web services e<posed b%
other or1ani=ations. #evelopers can use the 3##I 9usiness 5e1istr% to locate discover%
documents and service descriptions.
XML Web Service #iscover&'
XML Web service discover% is the process of locatin16 or discoverin16 one or more
related documents that describe a particular XML Web service usin1 the Web Services
#escription Lan1ua1e -WS#L.. It is throu1h the discover% process that XML Web
service clients learn that an XML Web service e<ists and where to find the XML Web
service:s description document.
+ published .disco file6 which is an XML document that contains lin8s to other resources
that describe the XML Web service6 enables pro1rammatic discover% of an XML Web
service. ?he followin1 shows an e<ample of the structure of a discover% document&
FG<ml versionHI1.0I GJ
Fdisco& discover% <mlns&discoHIhttp&DDschemas.<mlsoap.or1DdiscoI
<mlns&wsdlHIhttp&DDschemas.<mlsoap.or1DdiscoDwsdlIJ
Fwsdl&contract5ef refHIhttp&DDM%WebServerD3serAame.asm<GWS#LIDJ
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
FDdisco&discover%J
@owever6 a Web site that implements an XML Web service need not support discover%.
Bither another site could be responsible for describin1 the service6 such as an XML Web
services director%. +lternativel%6 there ma% not be a public means of findin1 the service6
such as when %ou create the service for private use.
XML Web Service #escri(tion
?he XML Web services infrastructure is founded on communication via XML;based
messa1es that compl% with a published service description. ?he service description is an
XML document written in an XML 1rammar called WS#L -Web Services #escription
Lan1ua1e. that defines the format of messa1es the XML Web service understands. ?he
service description serves as an a1reement that defines the behavior of an XML Web
service and instructs potential clients in how to interact with it. ?he behavior of an XML
Web service is determined b% messa1in1 patterns that the service defines and supports.
?hese patterns conceptuall% dictate what the service consumer can e<pect to happen
when a properl% formatted messa1e is submitted to the XML Web service.
)or e<ample6 the reEuestDresponse pattern associated with a remote procedure call -5,0.;
st%le service would define which S+, messa1e schema to use for invo8in1 a particular
method. ?his pattern would also define the format that the ensuin1 response S+,
messa1e will follow.
+nother e<ample of a messa1in1 pattern represents unidirectional interactions. ?his
pattern is emplo%ed when a one;wa% communication is to ta8e place. In this situation6 the
sender will not receive an% messa1es from the XML Web service6 includin1 fault
messa1es. + caveat to this is when the one;wa% communication is established usin1 a
protocol that is traditionall% reEuestDresponse6 where a fault messa1e ma% be returned.
?he schemas that define the S+, messa1e formats can be defined internall% to the
actual service description or6 the% can be defined e<ternall% and imported into service
description.
In addition to messa1e format definitions and messa1in1 patterns6 the service description
optionall% contains the address that is associated with each XML Web service entr%
point. ?he format of this address will be appropriate to the protocol used to access the
service6 such as a 35L for @??, or an e;mail address for SM?,.
XML Web Service Wire $or!ats'
9inar% protocols such as #0M consist of a method reEuest la%er ridin1 on top of a
proprietar% communication protocol. Such protocols are not conducive to creatin1
universall% available XML Web services. @owever6 this does not preclude %ou from
usin1 such protocols in an XML Web service scenario6 but the drawbac8 of usin1 them is
that such protocols depend on the specific architectures of their underl%in1 s%stems and
therefore limit the spectrum of potential clients.
+lternativel%6 %ou can construct XML Web services to wor8 with one or more open
protocols6 such as a combination of @??, and S+,. +s %ou would e<pect6 the
infrastructure reEuired to support different protocols will var%.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
XML Web services are not limited to providin1 remote procedure call -5,0. access.
?he% can also be built to e<chan1e structured information6 such as purchase orders and
invoices6 and can be used to automate and connect internal and e<ternal business
processes.
@??,;KB? and @??,;,S?
@??,;KB? and @??,;,S? are standard protocols that use @??, -@%perte<t ?ransfer
,rotocol. verbs for the encodin1 and passin1 of parameters as nameDvalue pairs6 alon1
with the associated reEuest semantics. Bach consists of a series of @??, reEuest headers
that amon1 other thin1s define what the client is reEuestin1 from the server6 which
responds with a series of @??, response headers and the reEuested data if successful.
@??,;KB? passes its parameters in the form of urlencoded te<t usin1 the MIMB t%pe
applicationD<;www;form;urlencoded6 which is appended to the 35L of the server
handlin1 the reEuest. 3rlencodin1 is a form of character encodin1 that ensures the passed
parameters consist of conformin1 te<t6 such as encodin1 a space as L20. ?he appended
parameters are also referred to as a Euer% strin1.
Similar to @??,;KB?6 @??,;,S? parameters are also urlencoded. @owever6 instead
of bein1 passed as part of the 35L6 the nameDvalue pairs are passed inside the actual
@??, reEuest messa1e.
SO)%
S+, is a simple6 li1htwei1ht XML;based protocol for e<chan1in1 structured and t%pe
information on the Web. ?he overall desi1n 1oal of S+, is to 8eep it as simple as
possible6 and to provide a minimum of functionalit%. ?he protocol defines a messa1in1
framewor8 that contains no application or transport semantics. +s a result6 the protocol is
modular and ver% e<tensible.
9% travelin1 over standard transport protocols6 S+, is able to levera1e the e<istin1
open architecture of the Internet and 1ain eas% acceptance b% an% arbitrar% s%stem
capable of supportin1 the most basic Internet standards. Mou could view the
infrastructure reEuired to support a S+,;compliant XML Web service as rather
simplistic6 %et powerful6 since it adds relativel% little to the e<istin1 infrastructure of the
Internet and still facilitates universal access to the services built with S+,.
?he S+, protocol specification consists of four main parts. ?he first part defines a
mandator% e<tensible envelope for encapsulatin1 data. ?he S+, envelope defines a
S+, messa1e and is the basic unit of e<chan1e between S+, messa1e processors.
?his is the onl% mandator% part of the specification.
?he second part of the S+, protocol specification defines optional data encodin1 rules
for representin1 application;defined data t%pes and directed 1raphs6 and a uniform model
for seriali=in1 non;s%ntactic data models.
?he third part defines an 5,0;st%le -reEuestDresponse. messa1e e<chan1e pattern. Bach
S+, messa1e is a one;wa% transmission. +lthou1h S+,:s roots are in 5,06 it is not
limited to bein1 a reEuestDresponse mechanism. XML Web services often combine S+,
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
messa1es to implement such patterns6 but S+, does not mandate a messa1e e<chan1e
pattern and this part of the specification is also optional.
?he fourth part of the specification defines a bindin1 between S+, and @??,.
@owever6 this part is also optional. Mou can use S+, in combination with an% transport
protocol or mechanism that is able to transport the S+, envelope6 includin1 SM?,6
)?, or even a flopp% dis8.
EX)M%LE 1 SO)% MESS)*E EMBE##E# I+ ,--% RE.UES-
,S? DStoc8Nuote @??,D1.1
@ost& www.stoc8Euoteserver.com
0ontent;?%pe& te<tD<ml> charsetHIutf;*I
0ontent;Len1th& nnnn
S+,+ction& ISome;35II
FS+,;BA4&Bnvelope
<mlns&S+,;BA4HIhttp&DDschemas.<mlsoap.or1DsoapDenvelopeDI
S+,;BA4&encodin1St%leHIhttp&DDschemas.<mlsoap.or1DsoapDencodin1DIJ
FS+,;BA4&9od%J
Fm&KetLast?rade,rice <mlns&mHISome;35IIJ
Fs%mbolJ#ISFDs%mbolJ
FDm&KetLast?rade,riceJ
FDS+,;BA4&9od%J
FDS+,;BA4&BnvelopeJ
/.Creatin0 XML web service usin0 visua" C1.net
4isual Studio.Aet provides an +S,.AB? Web Service project template to help us create
XML Web services in 4isual 9asic and 4isual 02.
-o create an )S%.+E- Web Service %ro2ect
1. n the $i"e menu6 point to +ew6 and then clic8 %ro2ect.
2. In the +ew %ro2ect dialo1 bo<6 select t3e Visua" C1 %ro2ects folder.
!. 0lic8 the )S%.+E- Web Service icon.
". Bnter the address of the Web server on which we will develop the XML Web
service and specif% -e!(Convert1 as the director% name6 such as
Ihttp&DDM%ServerD?emp0onvert1I. 9% default6 the project uses our local machine6
Ihttp&DDlocalhostI.
$. 0lic8 O4 to create the project.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
4isual Studio automaticall% creates the necessar% files and includes the needed references
to support an XML Web service. When we create an XML Web service project in 4isual
Studio6 we see the 0omponent #esi1ner for Service1.asm<.
Implementing the XML Web Service
?he ne<t step is to write the code to implement the functionalit% of the XML Web service
that clients will access. )or XML Web services created in 4isual Studio6 a hidden code;
behind file associated with the XML Web service:s .asm< file that 4isual Studio created
for us contains this code.
-o add an XML Web service !et3od
1. #ouble;clic8 the 0omponent #esi1ner:s desi1n surface to view the code;behind
file.
2. In the code;behind file6 locate the code for the Service1 class declaration. 5eplace
the S&ste!.Web.Services.WebService attribute code with the followin1 code
-shown in bold. before the class declaration&
!.
DD 02
5S&ste!.Web.Services.WebService6
+a!es(ace78X!"WebServices89
#escri(tion78) te!(erature conversion service.8:;
+ttachin1 the WebService attribute to a %ub"ic class ma8es it possible for us to
include additional information about the XML Web service6 such as a namespace
for the XML Web service and a description of the XML Web service. ?he
description propert% of this attribute is included in the Service help pa1e.
In the Service1 class6 we add the followin1 code to declare the
Convert-e!(erature function&
DD 02
OWebMethod-#escriptionHI?his method converts a temperature in I P
Ide1rees )ahrenheit to a temperature in de1rees 0elsius.I.Q
public double 0onvert?emperature-double d)ahrenheit.
R
return --d)ahrenheit ; !2. S $. D />
T
+ttachin1 the WebMet3od attribute to a %ub"ic method e<poses that method as part of
the XML Web service. ?he description propert% of this attribute is included in the
Service help pa1e and the Service method help pa1e. 5i1ht;clic8 Service1.as!< in
Solution B<plorer and then clic8 Set as Start %a0e on the shortcut menu.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
". Save the solution.
Deploying the XML Web Service
?o ma8e our XML Web service available to others6 we must deplo% it to a Web server
that is accessible to the clients . ?o deplo% the XML Web service to a server other than
the development server6 we can either add a Web Setup project or cop% the reEuired files
to the destination server.
-o de("o& t3e XML Web service usin0 a Web Setu( (ro2ect
1. n the $i"e menu6 point to )dd %ro2ect6 and then clic8 +ew %ro2ect.
2. Select the Setu( and #e("o&!ent %ro2ects folder6 and then clic8 Web Setu(
%ro2ect.
!. In the +a!e bo<6 t%pe -e!(Convert1WebSetu(6 and then clic8 O4.
". In the left pane of the $i"e S&ste! Editor6 select Web )(("ication $o"der.
$. In Solution B<plorer6 ri1ht;clic8 -e!(Convert1WebSetu(6 point to )dd6 and
then clic8 %ro2ect Out(ut.
'. In the )dd %ro2ect Out(ut *rou( dialo1 bo<6 select Content $i"es6 %ri!ar&
out(ut and #ebu0 S&!bo"s.
?he 0ontent )iles 1roup consists of the followin1 files for the XML Web
service& Service1.asm<6 Klobal.asa<6 and Web.confi1.
?he ,rimar% output 1roup consists of the project #LL6 ?emp0onvert1.dll6
and its dependencies.
?he #ebu1 S%mbols 1roup consists of the project ,#9 file6
?emp0onvert1.pdb.
(. 0lic8 O4.
*. In Solution B<plorer6 ri1ht;clic8 the -e!(Convert1WebSetu( project6 and then
on the shortcut menu6 clic8 Bui"d.
?his creates a Windows Installer file in the local project director%. B<ecutin1 this
file installs the Web application.
-o de("o& t3e XML Web service b& co(&in0 t3e (ro2ect
1. In Solution B<plorer6 select the -e!(Convert1 project.
2. n the %ro2ect menu6 clic8 Co(& %ro2ect.
!. In the #estination (ro2ect fo"der bo<6 enter the desired location to cop% the
project.
". 0lic8 either $ront%a0e or $i"e s3are to select a Web access !et3od.
$. 0lic8 On"& fi"es needed to run t3is a(("ication.
'. 0lic8 U.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
/. Web Server
E* O$ =)V) WEB SERVER' )%)C,E9 -OMC)-9 WEBLO*IC9 WEBS,ERE9 OR)CLE >I)S
MICROSO$- WEB SERVER' IIS
@+A#LIAK ) S+, MBSS+KB 9M WB9 SB54B5 & ? S3,,5? S+, +A# @BA0B WB9 SB54I0BS6
WB9 SB54B5 M3S? @+4B S+, LIS?BAB56 ?@B C9 ) LIS?BAB5 IS ? 0+LL ?@B WB9
SB54I0B +A# 5B?35A 5BS3L? +S S+, MBSS+KB- ?@B W5U )
M+5S@+LLIAKD3AM+5S@+LLIAK IA 5,0.
#onVt confuse that S+, messa1e will come to the browser6 the browser is capable of
displa%in1 @?ML onl%6 there will be S+, processor in the web server which is hostin1
the web server-+..
0lient +pplication
+pplication in IIS
>.)ccessin0 an XML Web Service Usin0 Visua" C1.net
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
1.Creating an XML Web Service Client Project
)irst we create a simple Web application that accesses the ?emp0onvert1 XML Web
service.
-o create an )S%.+E- Web a(("ication
1. n the $i"e menu6 point to +ew6 and then clic8 %ro2ect to open the +ew %ro2ect
dialo1 bo<.
2. B<pand the Visua" C1 %ro2ects folder.
!. 0lic8 the )S%.+E- Web )(("ication icon.
". Bnter the address of the Web server on which we will develop the Web
application and specif% -e!(ConvertC"ient1 as the director% name6 such as
Ihttp&DDM%ServerD?emp0onvert0lient1I. 9% default6 the project uses our local
machine6 Ihttp&DDlocalhostI.
$. 0lic8 O4 to create the project.
'. )rom the Web $or!s tab of the -oo"bo<6 dra1 a -e<t Bo<6 a Labe"6 and a
Button to the desi1n surface of Web$or!1.as(< and arran1e them to our li8in1.
(. 5i1ht;clic8 the button we added6 Button16 and clic8 %ro(erties on the shortcut
menu. In the %ro(erties window6 set the -e<t propert% to Convert.
*. 5i1ht;clic8 the label %ou added6 Labe"16 and clic8 %ro(erties on the shortcut
menu. In the %ro(erties window6 clear the -e<t propert% to ma8e this a blan8
label.
2. )ddin0 a Web Reference
XML Web service discover% is the process b% which a client locates an XML Web
service and obtains its service description. ?he process of XML Web service discover% in
4isual Studio involves interro1atin1 a Web site followin1 a predetermined al1orithm.
?he 1oal of the process is to locate the service description6 which is an XML document
that uses the Web Services #escription Lan1ua1e -WS#L..
?he service description describes what services are available and how to interact with
those services. Without a service description6 it is impossible to pro1rammaticall%
interact with an XML Web service.
Mour application must have a means to communicate with the XML Web service and to
locate it at run time. +ddin1 a Web reference to %our project for the XML Web service
does this b% 1eneratin1 a pro<% class that interfaces with the XML Web service and
provides a local representation of the XML Web service.
-o add a Web reference
1. n the %ro2ect menu6 clic8 )dd Web Reference.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
2. In the URL bo< of the )dd Web Reference dialo1 bo<6 t%pe the 35L to obtain
the service description of the XML Web service we want to access6 such as
3tt('??"oca"3ost?-e!(Convert1?Service1.as!<. ?hen clic8 the *o button to
retrieve information about the XML Web service.
!. In the Web reference na!e bo<6 rename the Web reference to ConvertSvc6
which is the namespace %ou will use for this Web reference.
". 0lic8 )dd Reference to add a Web reference for the tar1et XML Web service.
3. Acceing the XML Web Service
nce we add a reference for the XML Web service to our project6 the ne<t step is to
create an instance of the XML Web service:s pro<% class. We can then access the
methods of the XML Web service in the same manner that we access an% object:s
methods b% callin1 methods in the pro<% class. When our application calls these methods6
the pro<% class code 1enerated b% 4isual Studio handles the communications between
our application and the XML Web service.
)irst6 we will create an instance of the XML Web service:s pro<% class. Ae<t6 we will
ta8e a value6 provided in -e<tBo<16 and ma8e a call to the XML Web service:s
Convert-e!(erature method usin1 the pro<% class. We will then displa% the value
returned from the XML Web service in Labe"1.
-o access t3e XML Web service
1. #ouble;clic8 the Convert button on Web$or!1.as(< to create an event;handlin1
method for this button and to displa% the code;behind file.
2. Bnter the followin1 code
DD 02
protected void 9utton1W0lic8 -S%stem.bject sender6 S%stem.Bvent+r1s e.
R
tr%
R
0onvertSvc.Service1 ws H new 0onvertSvc.Service1-.>
double d)ahrenheit H 0onvert.?o#ouble-?e<t9o<1.?e<t.>
double d0elsius H ws.0onvert?emperature-d)ahrenheit.>
Label1.?e<t H d0elsius.?oStrin1-.>
T
catch
R
Label1.?e<t H I0onversion failed.I>
T
T
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
!. Select Web$or!1.as(< in Solution B<plorer.
". n the %ro2ect menu6 point to Web %ro2ect6 and then clic8 Set as Start %a0e.
$. Save the solution.
Conc"usion
XML Web services are enablin1 a new era of distributed application development. It is
no lon1er a matter of object model wars or pro1rammin1 lan1ua1e beaut% contests. When
s%stems are ti1htl% coupled usin1 proprietar% infrastructures6 it is done so at the e<pense
of application interoperabilit%. XML Web services deliver interoperabilit% on an entirel%
new level that ne1ates such counterproductive rivalries. +s the ne<t revolutionar%
advancement of the Internet6 XML Web services will become the fundamental structure
that lin8s to1ether all computin1 devices.
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
RE$ERE+CES'
1. 0oulouris6 #ollimore6 Uindber16X#istributed S%stems 0oncepts and #esi1n6
2
nd
edition6 +ddision;Wesle% 1//".
2. +.S.?anenbaum6 Y0omputer Aetwor8sX6 2nd edition6 ,@I 1//'
!. www.msdn.microsoft.com
". www.w!c.or1
$. #evelopin1 XML WB9 SB54I0BS and SB54B5 0M,ABA?S with
MI05S)? 4IS3+L 02 . AB?


www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com