Download presentation
Presentation is loading. Please wait.
Published byEverett Parker Modified over 9 years ago
1
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group
2
Agenda SQLXML Overview Data Access Methods FOR XML Queries over HTTP XPath Queries over HTTP Binary Data Xml Templates & Updategrams Web Servies
3
Demos Configuring SQL Server to work over HTTP (virtual directories) Executing Sql queries over HTTP Executing XPath queries over HTTP Xml Templates & Updategrams SQLXML Web Services
4
The Two Worlds SQLServer RowSet SQL Relational world Language Data storage Data output XML world XMLFiles XPathXQuery XML/HTML XMLView SQLXML – Bringing worlds together
5
Query/Update Technologies FOR XML (raw, auto, nested, explicit) SQL language extension to retrieve XML instead of rowsets XML Views – XPath Work with your relational database as if it was XML file (through annotated schema) Updategrams/Diffgrams Update through XML View Bulkload Shred large XML files into existing tables
6
Data Access Methods HTTP Access via URL SQL Query XPath Query XML Templates DBObjects Web services with SQL Virtual Directories ADO / OLEDB.NET access through SQLXML Managed Classes or ADO.NET Custom Web Services
7
HTTP access to SqlXml Easy as setting up a virtual directory Can query directly with query strings Best practices: Use templates for abstraction No blank sa passwords! Create the physical directory first
8
Steps: Configure XML support in IIS for SQL Server Launch Click the Start button and select Programs Microsoft SQL Server Configure SQL XML Support In IIS Create a new virtual directory Set physical path Configure connection security Choose data source
9
Steps: Configure XML support in IIS for SQL Server Configure access settings Allow URL Queries Allow Template Queries (*Default) Allow XPath Other tabs… Virtual Names (you will see this later) Advanced
10
Configuring XML support in IIS for Sql Server Irwin Dolobowsky Program Manager Webdata Group demo demo
11
Construct a simple HTTP Query SELECT * from Customers FOR XML AUTO Convert it to an HTTP request, by concatenating it with plus-sign (+) delimiters into: SELECT+*+FROM+CUSTOMERS+FOR+XML+AUTO Append that onto the URL for the virtual directory that you’ve created, by using the sql querystring parameter http://localhost/NorthwindCustomers?sql= SELECT+*+FROM+CUSTOMERS+FOR+XML+ AUTO
12
Execute SQL Queries over HTTP Irwin Dolobowsky Program Manager Webdata Group demo demo
13
XPath queries over HTTP Use XPath to query SQL Database as if it was an XML file Query over Xml View Mapping XSD to Relational Schema Much easier that FOR XML EXPLICIT Abstract away Database Steps Create annotated XSD (mapping/Xml View) Configure the virtual Schema directory Query against AXSD with XPath over HTTP
14
Execute XPath Queries over HTTP Irwin Dolobowsky Program Manager Webdata Group demo demo
15
Using DbObjects Enables you to return BLOBs Each query translates into a SQL statement Query returning a character column http://localhost/demos/dbobject/Employees[@EmployeeI D=1]/@LastName Query returning a blob column http://localhost/demos/dbobject/Employees[@EmployeeI D=1]/@Photo Query using parameters http://localhost/demos/dbobject/Employees[@EmployeeI D=$eid]/@Photo?eid=1
16
Working with Binary Large Objects Irwin Dolobowsky Program Manager Webdata Group demo demo
17
Working with BLOBs Techniques Base64 DBObject How to decide? Do you have access to the pointer (location) from DBObject? DBObject faster
18
Xml Templates XmlDocument with embedded queries FOR XML Queries XPath over Annotated XSD When template is executed, query results are filled in Dynamic XML document Parameterized Use templates over raw URL queries Get caching Encapsulation Security Control
19
Steps: XML Templates over HTTP Enable virtual directory settings Create query in template format Create the physical template directory Configure the virtual template mapping Save into XML file in template directory Just point to the template with a URL
20
Using sql:query SELECTCustomerID, CompanyName, City, Country FROM Customers FOR XML AUTO, ELEMENTS
21
Updategrams & XML Views Modify the database through the XML View Declare before and after images of the XML (what it is now, and what you want it to be) Optimistic concurrency control ensures that the transaction takes place only if the before image matches the current database state Each updategram is translated into one or more INSERT, UPDATE, and DELETE statements, carried out as a single transaction
22
Updategrams And XMLViews
23
XML Templates & Updategrams: Tying it all together Irwin Dolobowsky Program Manager Webdata Group demo demo
24
Web Services Overview Web Services expose Stored Procedures and XML Templates Messaging done according to SOAP 1.1 standard Variety of response options Can run on database server or mid-tier Wherever IIS is Simple UI for configuration Even DBA’s can do it!
25
What Does SQLXML Do For You? Creates Web Services Description Language (WSDL) file Describes Web Service Indicates what Methods are available Difficult to write by hand. WE DO IT FOR YOU! Parse SOAP requests Return proper SOAP response
26
Creating A Web Service Use the configuration tool to create a Virtual Directory (VDir) Create a Virtual Name of type “SOAP” Name your Web Service Give it a domain You Have a Web Service! Now to add some methods…
27
XML Template Methods Browse for an XML Template Choose Web Method name Results always returned in “XML Objects” mode
28
Stored Procedure Methods Select Stored Procedure from list Generated from login used for the VDir Choose Web Method name Select Output Formatting RAW or NESTED Select Response Type XML Objects Dataset Objects Single Dataset
29
Visual Studio.NET Integration SQLXML 3.0 Web Services designed for Visual Studio.NET In a Visual Studio.NET Project, “Add Web Reference” to your Web Service Proxy classes generated for your methods Forget that you are not accessing local information Visual Studio.NET takes care of the SOAP messaging and XML serialization / de- serialization for you
30
Exposing and Accessing SProcs as Web Services Irwin Dolobowsky Program Manager Webdata Group demo demo
31
Response Types All Responses are XML / SOAP Response Type dictates what Visual Studio.NET De-Serializes the XML into Other clients will just see XML
32
Single Dataset Response Limitations No Error Information Either a dataset comes back or it doesn’t, no other messages Single Result Sets Only Use Dataset Objects mode instead
33
Community Resources Main web page and download SQLXML releases at: http://msdn.microsoft.com/sqlxml/ Contacts news:microsoft.public.sqlserver.xml Email me: irwind@microsoft.com Documentation SQL Server 2000 Documentation (Books Online) Web Release documentation Books
34
Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx
35
Ask The Experts Get Your Questions Answered After this talk ATE – Now – 14:00
36
evaluations evaluations
37
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.