BuildData-DrivenWebServiceswithUpdatedSupportfor2000

来源:互联网 发布:java 调用泛型的方法 编辑:程序博客网 时间:2024/04/29 07:09
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Downloadthecodeforthisarticle:SQLXML3.exe(239KB)--->SUMMARYXMLisbecomingtheubiquitousdataformatontheWeb,andXMLsupportinSQLServerisevolvingtomeettheadditionaldemand.UsingXML,,HTTP,andSQLServer,youcannowbuildpowerfulWebServiceseasily.ToshowjusthowsimpleitiswithSQLXML3.0,thisarticlewalksthereaderthroughtheprocessstepbystep,fromsettingupavirtualdirectoryenablingdataaccessviaHTTPtoexecutingqueriesandbuildingWebServices.Finally,theauthorillustratesthecreationoftwoWebServicesclients梠newiththatworkswiththeMicrosoftandonewiththeSOAPToolkit2.0foranyonestillusingearlierdevelopmenttools.t'shardtobelievethatXMLsupportinSQLServer?2000hasbeenaroundforovertwoyears.Inthesoftwareworld,that'salifetime.SQLServer2000wasthefirstversiontoprovidenativesupport,andthiswaslimitedtothemorebasicXMLfeatureset(templatequeries,mappingschemas,andOPENXML).UsingsimpleHTTPqueriesyoucouldretrieveformattedrelationaldatainXMLformat.WithalittlehelpandsomeExtensibleStylesheetLanguage(XSL)magic,youcouldspitoutthedatainaformatted,-friendlymanner.Later,withtheintroductionoffeatureslikeupdategrams,youcouldeasilysubmitanXML-basedSQLtemplatetoinsertorupdaterowsofinformationinSQLServerwithlittleeffort.
Initially,IthoughtthatsomewouldconsiderXMLsupportafrivolousadditiontoanalreadypowerfulproduct.Ifadeveloperwasn'tdisplayingSQLdatainaWebpageorfeedingasystemthatonlyspeaksXML,werethesefeaturesallthatuseful?
Previously,theonlyviableapproachforaccessingdata,forthemiddle-tieranyway,wasthroughatraditionaldataaccesslayerbuiltwithODBC,OLEDB,orADO.NowwithSQLXML3.0,SQLServer2000,SOAP,BizTalk?andthe.NETFramework,XMLisnolongerafrivolousaddition梚t'sthedatalanguageofchoice.

UsingSQLXML3.0forData
SQLXML3.0isthethirditerationofXMLsupportforSQLServer.Thebiggestdifferencebetweentheoldwayofrepresentingdataandthewayit'srepresentedwithXMLishowtherowsetiscreated,whereitiscreated(server-sideorclient-side),andhowitisformatted(raw,nested,element-based,orattribute-based).Formoreonrawandexplicitformats,refertotheinformationlistedinthearticlesummary.
Forthoseofyoualreadyworkingwithsomeofthe.NETserverproductssuchasBizTalk,managedclasses,andthelike,youalreadyknowhowimportantitistouseXMLasyourdataformat.IfusingXMLfordataaccessisnewtoyou,thismaytakesomegettingusedto.IfyouchoosetouseXMLasyourdataformat,youmusttakeintoaccountthesubtledifferencesbetweenrelationalandhierarchicalrepresentationandhowyoucanexploitthebenefitsofahierarchy.
Ifyouareupgradingfromapreviousversion,youcanstillrunSQLXML3.0sidebysidewithyourcurrentversion.(Seethesidebars"Side-by-sideSupport"and"EvolutionofXMLSupport"formoreinformation.)

QueryingSQLServerwithXML
ThefastestwaytobeginaccessingSQLServer2000usingXMListhroughyourbrowser.Thisisagreatwaytocheckwhetheryouhaveeverythingsetupcorrectly,andisalsoyourfirstmeansofdiagnosingproblemsshouldtheyappear.ToaccessSQLServerusingaURLviathebrowseroranyHTTPclient,youmustfirstsetupavirtualdirectoryforSQLServerusingtheMicrosoft?ManagementConsole(MMC)snap-inprovidedwithanyofthereleases.
Ifyouwanttosetupavirtualdirectorytoperformtemplatequeries,youcanstillusetheMMCsnap-inprovidedwiththeoriginalinstallationofSQLServer.ThiscanbefoundintheSQLServer2000programgroupunderConfigureSQLXMLSupportinIIS.However,totakeadvantageofSQLXML3.0features,IrecommendselectingtheMMCsnap-infoundintheSQLXML3.0programgroupunderConfigureIISSupport.Hereyoucanconfigureallfeaturesuptoandincludingthoseofversion3.0.
Tosetupavirtualdirectory,firstyouneedtosetupadirectorystructurewithamaindirectory(Icalledmineprojects)thathastwosubdirectories:templateandSOAP.ThetemplatedirectorywillcontainyourXMLtemplatefilesandwillbeusedforalltemplateoperations(forexample,file-basedSQL,XPath,updategrams,andsoon).TheSOAPdirectorywillcontainallfilesrequiredforaccessingSQLServerviaWebServices.Ifyouwanttoexperimentwithmappingschemas(viatheschematype)and/ordirectdatabaseobjectaccess(viathedbobjecttype),thenyoumayadddirectoriesforeachofthoseaswell.FollowthesestepsfortestingyourinstallationwithasimpleXMLquery.1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击