亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > XML > 正文

Build Data-Driven Web Services with updated XML Su

2024-07-21 02:09:10
字體:
來源:轉載
供稿:網友
  • 網站運營seo文章大全
  • 提供全面的站長運營經驗及seo技術!
  • download the code for this article: sqlxml3.exe (239kb) --->summary xml is becoming the ubiquitous data format on the web, and xml support in sql server is evolving to meet the additional demand. using xml, soap, http, and sql server, you can now build powerful web services easily. to show just how simple it is with sqlxml 3.0, this article walks the reader through the process step by step, from setting up a virtual directory enabling data access via http to executing queries and building web services. finally, the author illustrates the creation of two web services clients梠ne with c# that works with the microsoft .net framework and one with the soap toolkit 2.0 for anyone still using earlier development tools. t's hard to believe that xml support in sql server?2000 has been around for over two years. in the software world, that's a lifetime. sql server 2000 was the first version to provide native support, and this was limited to the more basic xml feature set (template queries, mapping schemas, and openxml). using simple http queries you could retrieve formatted relational data in xml format. with a little help and some extensible stylesheet language (xsl) magic, you could spit out the data in a formatted, html-friendly manner. later, with the introduction of features like updategrams, you could easily submit an xml-based sql template to insert or update rows of information in sql server with little effort.
    initially, i thought that some would consider xml support a frivolous addition to an already powerful product. if a developer wasn't displaying sql data in a web page or feeding a system that only speaks xml, were these features all that useful?
    previously, the only viable approach for accessing data, for the middle-tier anyway, was through a traditional data access layer built with odbc, ole db, or ado. now with sqlxml 3.0, sql server 2000, soap, biztalk? and the .net framework, xml is no longer a frivolous addition梚t's the data language of choice.

    using sqlxml 3.0 for data access
    sqlxml 3.0 is the third iteration of xml support for sql server. the biggest difference between the old way of representing data and the way it's represented with xml is how the rowset is created, where it is created (server-side or client-side), and how it is formatted (raw, nested, element-based, or attribute-based). for more on raw and explicit formats, refer to the information listed in the article summary.
    for those of you already working with some of the .net server products such as biztalk, managed classes, and the like, you already know how important it is to use xml as your data format. if using xml for data access is new to you, this may take some getting used to. if you choose to use xml as your data format, you must take into account the subtle differences between relational and hierarchical representation and how you can exploit the benefits of a hierarchy.
    if you are upgrading from a previous version, you can still run sqlxml 3.0 side by side with your current version. (see the sidebars "side-by-side support" and "evolution of xml support" for more information.)

    querying sql server with xml
    the fastest way to begin accessing sql server 2000 using xml is through your browser. this is a great way to check whether you have everything set up correctly, and is also your first means of diagnosing problems should they appear. to access sql server using a url via the browser or any http client, you must first set up a virtual directory for sql server using the microsoft?management console (mmc) snap-in provided with any of the releases.
    if you want to set up a virtual directory to perform template queries, you can still use the mmc snap-in provided with the original installation of sql server. this can be found in the sql server 2000 program group under configure sql xml support in iis. however, to take advantage of sqlxml 3.0 features, i recommend selecting the mmc snap-in found in the sqlxml 3.0 program group under configure iis support. here you can configure all features up to and including those of version 3.0.
    to set up a virtual directory, first you need to set up a directory structure with a main directory (i called mine projects) that has two subdirectories: template and soap. the template directory will contain your xml template files and will be used for all template operations (for example, file-based sql, xpath, updategrams, and so on). the soap directory will contain all files required for accessing sql server via web services. if you want to experiment with mapping schemas (via the schema type) and/or direct database object access (via the dbobject type), then you may add directories for each of those as well. follow these steps for testing your installation with a simple xml query.
    to create the template virtual directory in the mmc, select default web site, then new virtual directory.
    on the general tab, name the virtual directory to match the database you will be accessing. i simply use northwind (see figure 1). this becomes the virtual directory upon which you will access any xml feature. set this root directory to contain all templates.


    figure 1 good ol'northwind

    on the security tab, select the authentication scheme you will use to access the database.
    on the data source tab, select your data source.
    on the settings tab, select "allow sql= ..." and select "allow template queries." these two will be enough to get you going. later you will select "allow post" to enable calls to sql server as a web service.
    on the virtual names tab (see figure 2), select <new virtual name>, call it "template," specify the template type, and point it to the template subdirectory that should now reside under your main directory.


    figure 2 defining a new virtual name

    name the template "customers.xml" and save it under your template subdirectory. any sql command can be added to this file. both updategrams and bulk loading can be used for updates or inserts from the template directory as well. here you can see a sample xml query template for retrieving all customers from the northwind database:

    <root xmlns:sql="urn:schemas-microsoft-com:xml-sql"> <sql:query client-side-xml="0"> select * from customers for xml auto </sql:query> </root>
    now execute the following in your browser: http://localhost/northwind/template/customers.xml. you should see the xml query results shown in figure 3 (not fancy but functional). if so, your queries are working and now you can proceed to the more advanced features of sqlxml 3.0.
    getting started with sqlxml web services
    if you are already doing .net development, then you know that building web services is quite simple. through visual studio?.net and the runtime's use of attributes such as webservice and webmethod, you can quickly produce reliable web services. even more advanced functionality such as passing soap headers or hooking soap requests passed into a .net web service (trace extensions) becomes less daunting with .net.
    if you aren't using the .net runtime in your environment yet (sense my bias?), a little more elbow grease may be required. you can use the soap toolkit 2.0, but that requires more background in how soap is used to send and receive data from a web service. overall, however, building a non-.net client is very similar to working with a web service proxy in .net. if you don't have .net, or you don't want to build an entire data access/web services framework, sqlxml 3.0 is for you.
    sqlxml 3.0 provides a web service middle tier in the form of an isapi library (sqlis3.dll). all you need to do is configure sqlxml and provide a web services client. with sqlxml you can now send soap http requests to a server running sqlxml 3.0 to execute a stored procedure, xml template, or udf directly. the requested operation is executed at the data source and a soap response is returned to the client. the web services magic, at least on the server, is all taken care of by sqlxml. just configure the web service using the same mmc snap-in as i demonstrated in the previous section for templates. the only code required is on the client. this can be an asp or asp.net application, a microsoft windows?application, a console application, or whatever. the client can be built using c#, a standard soap client using straight xml, or even the soap toolkit 2.0. in this article i will demonstrate client development by building a simple c# client (using the visual studio-generated web services proxy) and a visual basic?client (using the soap toolkit).

    setting up a sqlxml web service
    if you are following along with my sample, use these steps to configure the web service:
    select the northwind virtual directory that you created in the previous section and display its properties.
    select the settings tab and make sure allow post is checked so that soap requests can be posted from the client.
    select the virtual names tab and select <new virtual name> as you did to create the template type.
    select the soap type and give it a name. i called mine "soapprocedures." you can name it anything you want and you can have as many defined soap types as you like. for each defined soap type, sqlxml creates a corresponding configuration file (.ssc) and a web services description language (wsdl) file that are used to access the web service. it is important to note that these files are named after the web service you provided, not the soap type. the soap type's name is used to retrieve the generated wsdl file, which describes the service and the operations (stored procedures, udfs, and templates) that a client can then request.
    select a directory to map this soap type. use the soap directory created earlier. this is where the .ssc and wsdl files will be created. select save.
    finally, give your web service a name. i called mine "procedures." this is the name you will use from your client code to instantiate the web service using the proxy in .net. figure 4 shows the wsdl output for this web service. you'll notice that under iis, your virtual directory (northwind) will have a soap directory and two files: procedures.ssc and procedures.wsdl. note that by default you can't select the wsdl file directly from the browser. you need this uri: http://localhost/northwind/soapprocedures?wsdl.
    when the new soap type is selected, select configure.
    under the soap virtual name configuration dialog, select <new method mapping>.
    select a mapping type (sp for stored procedures and user-defined functions).
    select the stored procedure using the browse button, and give it a method name. the name will be the invokable web method you will use from the client. keep the remaining defaults. for my example i selected two stored procedures from the northwind database, salesbycategory and custorderhist, and kept the default, which simply uses the stored procedure name.
    test the wsdl file that contains the web methods created from your browser as you did in the section "setting up a sqlxml virtual directory." now let's build the clients.
    a sqlxml web services client using c#
    the quickest way to get up and running with web services is to write your client using the .net framework. as you will see, it isn't the amount of code saved that makes .net simpler to use. most of you can get away without knowing the underpinnings of the soap protocol since the proxy generated from visual studio does all of the work. however, learning some of the basic elements of soap would be smart. for my simple example, i use c# to call the newly configured web service.
    i created a new client application using visual studio .net. the client can be any type of application. for this example, i am using a c# application for windows. sqlxml web services can be called like any other web service. add a web reference from the add web reference dialog type in the same url you used to test the wsdl file (http://localhost/northwind/soapprocedures?wsdl). in figure 5 the getallcustomers template has been called as a web service and its xml results used in a dataset grid. figure 6 shows the sample client using asp.net.
    the wsdl output should appear in the left pane of the visual studio ide. from here, you can add the reference to your project. i added the procedures.wsdl reference, allowing me to declare a variable of this web reference type. once declared, i treat this type like any other class type in .net by instantiating it. after the web service object is created, i can invoke its operations by calling any of its exposed methods. intellisense?should now display each of these web methods in the editor.
    the following c# code shows how to call a stored procedure wrapped as a web service. i've omitted a few details that i will explain shortly. you can see that calling a web service at this point is very similar to calling into any other object type:

    localhost.procedures owsprocs = new localhost.procedures();int nreturnvalue;晻?= owsprocs.custorderhist("alfki", out nreturnvalue);
    you'll notice that this call differs from standard calls to web services in the return values. when using sqlxml web services, the data returned from the web method takes the form of an object array, which must then be cast into a workable type like xmlelement or sqlmessage.
    xmlelement objects include the result that is successfully returned by sqlxml after executing any operations (stored procedure, template, or udf). in the wsdl file this is defined as having a sqlxml complex type. error messages returned from sqlxml are of type sqlmessage. if sql server returns one or more errors, this sqlmessage complex type is returned as part of the object array and is also defined in the wsdl file. (more on this later.)
    the system.xml.xmlelement complex type maps directly into an xml node class type from the .net class library. if you have worked with .net and xml you should already be familiar with this stock type. sqlmessage is a custom type specific to sqlxml and contains any error messages generated during transport. to make sense of the returned object array from a sqlxml web service, i created the xmlelement method. in figure 7 you can see how the object array is handled.
    this method takes any returned object array and either returns an array of xmlelement types or throws an exception, filling in the values from the sqlmessage type. to determine if the object array contains an error or xml instance data, the type is determined by using gettype and the value is cast appropriately. xmlelements are simply returned to the caller. figure 8 shows the calling code in its entirety. (this is slightly different from this article's downloadable code for clarity.)
    i have not yet mentioned the system.data.dataset type. just because data is being transported via xml, soap, and ultimately sqlxml doesn't mean you cannot use datasets to your advantage. datasets are terrific at providing the perfect data container, not to mention being handy for purposes such as displaying data in a grid.
    it's easy to return xml instance data from a stored procedure (callable from a sqlxml web service) and turn it into an xml schema-based dataset, ready to be consumed as you please. to perform this conversion i created a method called getdatasetfromxmlfragment which takes any xml fragment, infers an xml schema, and hydrates its data. the managed sqlxml classes can also be used in similar fashion.
    the following code shows how the system.xml.xmlreader and the dataset's readxml work together to fill a dataset:

    public static dataset getdatasetfromxmlfragment(xmlelement oxml){dataset ds = new dataset(); xmltextreader oreader = new xmltextreader(oxml.outerxml, xmlnodetype.element, new xmlparsercontext(null, null, null, xmlspace.none)); // now lets create a schema off of the instance data ds.readxml(oreader, xmlreadmode.inferschema); return ds;}
    don't forget, value types such as integer and float cannot be passed or returned as a null value when using the proxy classes that are generated by visual studio .net. to do so, you must create your own web service proxy class (which is not recommended). reference types and string types can be null.

    calling templates and udfs as web services
    along with stored procedures, sqlxml also allows web services to call xml templates and udfs. configuring these types is not very different from working with stored procedures. the configuration process establishes the necessary mapping in a wsdl file as before. once configured, the mapping is used to execute the corresponding template or udf just like you do with stored procedures. if you want to configure a template to use with my sample, complete the following steps:
    go to the properties dialog of the northwind virtual directory.
    on the virtual names tab, select the soapprocedures soap type created earlier and select configure.
    select template as the edit/new mapping type.
    select the browse button. from there you can find any previously built xml template.
    select the customers.xml template that you have used already to test the installation of sqlxml 3.0 and call it getallcustomers.
    that's it. you can now call getallcustomers as a web service just like you'd call the stored procedures. getallcustomers will return all of the records from the customers table as xml, but instead of using a browser i can now capture this in code. i believe this is where this release really shines. those of you who have invoked templates in code via http or through one of the ole db providers as i discussed in my article "biztalk and xml: add e-commerce to your app with xml and sql server 2000," (msdn magazine january 2002) will now appreciate the simplicity of uniformly invoking all operations as web services.
    invoking a udf is no different. you can build the udf shown in figure 9 by following the same steps just outlined and selecting sp as the edit/new mapping type as you did when configuring a callable stored procedure. all udfs and stored procedures should appear in the browse dialog. make sure you update your web reference from visual studio .net. (intellisense will tell you when it is there, or you can look at the generated wsdl.)

    using the soap toolkit 2.0
    many of you may not yet have the option of using .net technology in your development environment. if that's the case, you can invoke any sqlxml feature using plain old visual basic?6.0. the only additional component required prior to running the following sample code is the soap toolkit 2.0. i invoke the exact same operations i created here already except i will do it from visual basic 6.0. familiarity with the msxml document object model (dom) would be helpful, but it's not required. the only two interfaces that are required are the ixmldomnodelist and ixmldomnode interfaces from msxml 4.0.
    figure 10 looks amazingly similar to the c# sample. the major difference here is that i am doing this from a visual basic 6.0-based client and i am using the soapclient component from the soap toolkit 2.0 for the proxy. soapclient is used exactly like the generated proxy from visual studio .net. instead of binding the return values from an object array to a data type, you will always be using an ixmldomnodelist from msxml 4.0 to iterate through each returned ixmldomnode. here you are simply working with the msxml node interfaces. the output from running this code is not quite as neat as you saw in the .net example. it could be much improved with a little xsl. i'll leave the rest up to you.

    conclusion
    in this article i introduced sqlxml 3.0 and its most powerful application: web services using soap. for environments not ready for .net, or those of you without the inclination to build a custom middle tier, sqlxml 3.0 provides a simple yet effective way to access sql server over the wire. hierarchical data in the form of xml has become the data format of choice among developers. xml and soap will give you an advantage in the loosely coupled world of web services. to download the latest web release (sqlxml version 3.0) or to find more information on the new features offered in the xml for sql server web releases, see http://msdn.microsoft.com/xml.
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
    日韩性生活视频| 中文字幕少妇一区二区三区| 97精品国产97久久久久久春色| 欧美日韩亚洲一区二区三区| 国产精品igao视频| 国外成人性视频| 国产精品久久久av| xxxxx91麻豆| 成人精品aaaa网站| 亚洲自拍偷拍一区| 亚洲男人第一网站| 日韩成人激情影院| 伊人久久久久久久久久久久久| 久久久久久网址| 亚洲国产中文字幕久久网| 亚洲视频在线视频| 欧美在线观看一区二区三区| 欧美日韩亚洲视频| 精品亚洲男同gayvideo网站| 亚洲mm色国产网站| 精品美女永久免费视频| 黄色成人av网| 亚洲免费中文字幕| 国产日韩欧美黄色| 97国产精品人人爽人人做| 成人动漫网站在线观看| 欧美激情视频三区| 麻豆国产va免费精品高清在线| 国产成+人+综合+亚洲欧洲| 亚洲自拍在线观看| 岛国av一区二区在线在线观看| 欧美在线视频播放| 国产精品爱久久久久久久| 黑人巨大精品欧美一区二区| 免费91在线视频| 国产精品欧美日韩久久| 日韩av综合网| 欧美激情一区二区久久久| 97国产精品久久| 日韩欧美中文字幕在线播放| 欧美成在线观看| 国产香蕉一区二区三区在线视频| 欧美视频13p| 日韩大片免费观看视频播放| 久久视频中文字幕| 国产精品久久久av久久久| 国产一区二区三区在线视频| 久久久久久18| 国产性猛交xxxx免费看久久| 国产精品高潮呻吟久久av黑人| 精品中文视频在线| 国产亚洲日本欧美韩国| 国产精品第一第二| 久久天天躁日日躁| 欧美黄色性视频| 清纯唯美日韩制服另类| 成人免费观看网址| 日本精品视频在线播放| 亚洲欧美日韩精品| 成人激情视频小说免费下载| 国产欧美精品久久久| 夜夜嗨av色一区二区不卡| 欧美在线观看网址综合| 久操成人在线视频| 欧美韩日一区二区| 亚洲va欧美va在线观看| 欧美综合在线第二页| 性色av一区二区三区| 亚洲精品自拍偷拍| 亚洲精品理论电影| 久久久久日韩精品久久久男男| 国产精品高潮在线| 中文字幕av一区| 亚洲欧洲在线视频| 日韩福利伦理影院免费| 美日韩精品免费观看视频| 亚洲电影av在线| 欧美一级大胆视频| 国产精品夜色7777狼人| 国产免费一区二区三区在线能观看| 国产精品久久久久aaaa九色| 一区二区三区在线播放欧美| 欧美色道久久88综合亚洲精品| 欧美大成色www永久网站婷| 国产欧美日韩免费| 日本精品va在线观看| 欧美视频一区二区三区…| 国产精品亚洲网站| 国产精品国产福利国产秒拍| 日韩在线小视频| 成人写真视频福利网| 欧美日韩亚洲一区二| 亚洲精品黄网在线观看| 亚洲影视中文字幕| 亚洲激情国产精品| 精品国产31久久久久久| 狠狠久久亚洲欧美专区| 国产精品夜间视频香蕉| 久久精品人人做人人爽| 欧美色欧美亚洲高清在线视频| 欧美电影在线播放| 2019中文字幕在线免费观看| 亚洲伦理中文字幕| 456亚洲影院| 中文字幕日本精品| 亚洲护士老师的毛茸茸最新章节| 欧美老少配视频| 日韩av在线网站| 久久影院模特热| 欧美精品情趣视频| 亚洲精品免费网站| 91久久久久久国产精品| 久久久久国产一区二区三区| 欧美中文字幕视频| 最新69国产成人精品视频免费| 91高清视频免费| 亚洲成色999久久网站| 国产成人精品视频在线| 日本道色综合久久影院| 国产高清视频一区三区| 国内精品久久久久久久久| 亚洲欧美自拍一区| 欧美一级淫片播放口| 亚洲美女av网站| 欧美午夜性色大片在线观看| 欧美最顶级丰满的aⅴ艳星| 综合网日日天干夜夜久久| 国产精品久久网| 亚洲欧洲国产一区| 国产精品免费一区豆花| 粗暴蹂躏中文一区二区三区| 亚洲色图国产精品| 丝袜亚洲另类欧美重口| 国产99久久精品一区二区 夜夜躁日日躁| 91av在线网站| 欧美成人精品h版在线观看| 国产不卡在线观看| 日韩高清不卡av| 在线精品视频视频中文字幕| 国产亚洲精品久久久| 中日韩美女免费视频网站在线观看| 57pao国产精品一区| 亚洲大胆人体av| 中文字幕不卡在线视频极品| 久久这里有精品| 成人av电影天堂| 欧美理论电影在线观看| 国产精品亚洲综合天堂夜夜| 国产成人综合久久| 自拍偷拍免费精品| 欧美成人中文字幕| 日韩成人在线视频观看| 国产一区玩具在线观看| 成人在线国产精品| 久久影视电视剧免费网站| 欧美有码在线观看视频| 麻豆精品精华液| 亚洲视频免费一区| 日韩电影中文 亚洲精品乱码| 中文字幕免费精品一区| 在线中文字幕日韩| 91美女片黄在线观看游戏| 国产精品吹潮在线观看| 国产精品白丝av嫩草影院|