Download DAT304

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Resource Description Framework wikipedia , lookup

Database wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft Access wikipedia , lookup

Web analytics wikipedia , lookup

Semantic Web wikipedia , lookup

Database model wikipedia , lookup

Versant Object Database wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

XML wikipedia , lookup

Transcript
DAT304
Leveraging XML and HTTP with
Sql Server
Irwin Dolobowsky
Program Manager
Webdata Group
Agenda
SQLXML Overview
Data Access Methods
FOR XML Queries over HTTP
XPath Queries over HTTP
Binary Data
Xml Templates & Updategrams
Web Servies
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
The Two Worlds
Language
SQL
Data
storage
SQL
Server
Data
output
XPath
XQuery
XML
View
RowSet
Relational
world
SQLXML
–
Bringing
worlds
together
XML
Files
XML/
HTML
XML
world
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
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
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
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
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
demo
Configuring XML support
in IIS for Sql Server
Irwin Dolobowsky
Program Manager
Webdata Group
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
demo
Execute SQL Queries
over HTTP
Irwin Dolobowsky
Program Manager
Webdata Group
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
demo
Execute XPath Queries
over HTTP
Irwin Dolobowsky
Program Manager
Webdata Group
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
demo
Working with Binary
Large Objects
Irwin Dolobowsky
Program Manager
Webdata Group
Working with BLOBs
Techniques
Base64
DBObject
How to decide?
Do you have access to the pointer (location)
from DBObject?
DBObject faster
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
Steps: XML Templates over HTTP
Enable virtual directory settings
Create query in template format
<sql:query></sql:query>
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
Using sql:query
<NWCustomers
xmlns:sql="urn:schemasmicrosoft-com:xml-sql">
<sql:query>
SELECT
CustomerID,
CompanyName,
City, Country
FROM
Customers
FOR XML AUTO, ELEMENTS
</sql:query>
</NWCustomers>
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
Updategrams And XMLViews
<updategram-example>
<updg:sync mapping-schema=“schema.xsd”
xmlns:updg=“urn:schemas-microsoft-com:xml-updategram”>
<updg:before>
<Customer CustomerID=“LAZYK” Address=“12 Orchestra
Terrace”>
<Order OrderID=“27” UnitPrice=“100” Quantity=“1000” />
</Customer>
</updg:before>
<updg:after>
<Customer CustomerID=“LAZYK” Address=“8 Opera Court”/>
</updg:after>
</updg:sync>
</updategram-example>
demo
XML Templates &
Updategrams:
Tying it all together
Irwin Dolobowsky
Program Manager
Webdata Group
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!
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
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…
XML Template Methods
Browse for an XML Template
Choose Web Method name
Results always returned in “XML Objects”
mode
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
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 / deserialization for you
demo
Exposing and Accessing
SProcs as Web Services
Irwin Dolobowsky
Program Manager
Webdata Group
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
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
Community Resources
Main web page and download SQLXML
releases at:
http://msdn.microsoft.com/sqlxml/
Contacts
news:microsoft.public.sqlserver.xml
Email me: [email protected]
Documentation
SQL Server 2000 Documentation (Books Online)
Web Release documentation
Books
Community Resources
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
Ask The Experts
Get Your Questions Answered
After this talk
ATE – Now – 14:00
evaluations
© 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.