DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program...
-
Upload
melanie-turner -
Category
Documents
-
view
215 -
download
1
Transcript of DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program...
DAT 330DAT 330
Building Web Services with Building Web Services with SQL Server and SQLXML 3.0SQL Server and SQLXML 3.0
Alexander VaschilloAlexander VaschilloLead Program ManagerLead Program ManagerWebData XML GroupWebData XML GroupMicrosoft CorporationMicrosoft Corporation
SQLXML TalksSQLXML Talks SQLXML: XML Technology for SQL SQLXML: XML Technology for SQL
ServerServer DAT200, Alexander Vaschillo, DAT200, Alexander Vaschillo, Jul 2 8:30Jul 2 8:30
Building Web Services with SQL Server Building Web Services with SQL Server and SQLXML 3.0and SQLXML 3.0 DAT330, Alexander Vaschillo, DAT330, Alexander Vaschillo, Jul 2 18:15Jul 2 18:15
Inside data access with SQLXML: Inside data access with SQLXML: Architecture guideArchitecture guide DAT400, Alexander Vaschillo, DAT400, Alexander Vaschillo, Jul 3 10:00Jul 3 10:00
AgendaAgenda
SQLXML OverviewSQLXML Overview SQL ServerSQL Server 2000 Web Services 2000 Web Services
OverviewOverview What can be exposedWhat can be exposed What does SQLXML 3.0 do for youWhat does SQLXML 3.0 do for you
How to create a Web ServiceHow to create a Web Service Setting up a Web ServiceSetting up a Web Service Available OptionsAvailable Options
Support for Visual Studio.NETSupport for Visual Studio.NET DemoDemo
The Two WorldsThe Two Worlds
SQLSQLServerServer
RowSetRowSet
SQLSQL
Relational Relational worldworld
LanguageLanguage
Data Data storagestorage
Data Data outputoutput
XML XML worldworld
XMLXMLFilesFiles
XPathXPathXQueryXQuery
XML/XML/HTMLHTML
XMLXMLViewView
SQLXML SQLXML – –
Bringing Bringing worlds worlds
togethertogether
Query/Update TechnologiesQuery/Update Technologies
FOR XML (raw, auto, nested, explicit)FOR XML (raw, auto, nested, explicit) SQL language extension to retrieve XML SQL language extension to retrieve XML
instead of rowsetsinstead of rowsets
XML Views – XPath, XQueryXML Views – XPath, XQuery Work with your relational database as if it was Work with your relational database as if it was
XML file (through annotated schema)XML file (through annotated schema)
Updategrams/DiffgramsUpdategrams/Diffgrams Update through XML ViewUpdate through XML View
BulkloadBulkload Shred large XML files into existing tablesShred large XML files into existing tables
Data Access MethodsData Access Methods HTTP Access via URLHTTP Access via URL
SQL QuerySQL Query XPath QueryXPath Query XML TemplatesXML Templates
ADO / OLEDBADO / OLEDB .NET access through SQLXML .NET access through SQLXML
Managed ClassesManaged Classes Web ServicesWeb Services
SQLXML 3.0SQLXML 3.0
Introduces Web Services for SQL Server Introduces Web Services for SQL Server Turn your SQL Server into a Web Turn your SQL Server into a Web
Service in 15 minutesService in 15 minutes Released at Visual Studio.NET Launch, Released at Visual Studio.NET Launch,
February 2002February 2002 Localized to 8 languages at launchLocalized to 8 languages at launch Integral part of Microsoft’s .NET visionIntegral part of Microsoft’s .NET vision
Web Services OverviewWeb Services Overview
Web Services expose Stored Web Services expose Stored Procedures and XML TemplatesProcedures and XML Templates
Messaging done according to SOAP 1.1 Messaging done according to SOAP 1.1 standardstandard
Variety of response optionsVariety of response options Can run on database server or mid-tierCan run on database server or mid-tier
Wherever IIS isWherever IIS is
Simple UI for configurationSimple UI for configuration Even DBA’s can do it!Even DBA’s can do it!
What can be exposed?What can be exposed?
XML TemplatesXML Templates XML returned from template is simply XML returned from template is simply
returned from the Web Servicereturned from the Web Service
Stored ProceduresStored Procedures Relational data converted to XML Relational data converted to XML XML Data is returnedXML Data is returned Output Parameters also returnedOutput Parameters also returned
UDF’s- Visible like a store procedureUDF’s- Visible like a store procedure
What does SQLXML do for What does SQLXML do for you?you? Creates Web Services Description Creates Web Services Description
Language (WSDL) fileLanguage (WSDL) file Describes Web ServiceDescribes Web Service Indicates what Methods are availableIndicates what Methods are available Difficult to write by hand. WE DO IT FOR Difficult to write by hand. WE DO IT FOR
YOU!YOU!
Parses SOAP requestsParses SOAP requests Returns proper SOAP responseReturns proper SOAP response
How is it done?How is it done?
Admin creates a Web Service and adds Admin creates a Web Service and adds Web Methods via a simple UIWeb Methods via a simple UI Web Methods map to Stored Procedures Web Methods map to Stored Procedures
and Templatesand Templates WSDL file is createdWSDL file is created
Client retrieves WSDL via URLClient retrieves WSDL via URL http://doman/vDir/vName?wsdlhttp://doman/vDir/vName?wsdl
Client now knows the methods available Client now knows the methods available Method namesMethod names ParametersParameters Return ValuesReturn Values
How is it done (continued)?How is it done (continued)?
Client application sends SOAP encoded Client application sends SOAP encoded request (Procedure call)request (Procedure call) POST to SOAP vNamePOST to SOAP vName
SQLXML parses requestSQLXML parses request Method NameMethod Name ParametersParameters
XML Template or Stored Procedure is XML Template or Stored Procedure is calledcalled Client has no idea that this is a template or Client has no idea that this is a template or
stored procedure, or even that it’s SQL stored procedure, or even that it’s SQL ServerServer
How is it done (continued)?How is it done (continued)?
Proper SOAP encoded response is Proper SOAP encoded response is constructed and returned to the clientconstructed and returned to the client
For methods mapping to XML For methods mapping to XML Templates, results are already XMLTemplates, results are already XML Results are wrapped in SOAP envelope and Results are wrapped in SOAP envelope and
returnedreturned For methods mapping to stored For methods mapping to stored
procedures, results are processedprocedures, results are processed Results are converted to XML according to Results are converted to XML according to
options chosenoptions chosen XML is wrapped in SOAP envelope and XML is wrapped in SOAP envelope and
returnedreturned
ArchitectureArchitecture
Web Web ServerServer
Virtu
al Directo
ryV
irtual D
irectory
SOAP SOAP VNameVName
WSDLWSDLWSDLWSDL
MethodMethod
MethodMethod
MethodMethod
XML XML TemplateTemplatess
XML XML TemplateTemplatess
SQL SQL Server Server 20002000
SP’sSP’sSP’sSP’s
Config / Config / MappingMappingFileFile
Config / Config / MappingMappingFileFile
Creating a Web ServiceCreating a Web Service
Use the configuration tool to create a Use the configuration tool to create a Virtual Directory (VDir)Virtual Directory (VDir)
Create a Virtual Name of type “SOAP”Create a Virtual Name of type “SOAP” Name your Web ServiceName your Web Service Give it a domainGive it a domain
You Have a Web Service!You Have a Web Service!
Now to add some methods…Now to add some methods…
XML Template MethodsXML Template Methods
Browse for an XML TemplateBrowse for an XML Template All templates available on the SQLXML All templates available on the SQLXML
tiertier
Choose Web Method nameChoose Web Method name Results always returned in “XML Results always returned in “XML
Objects” modeObjects” mode
Stored Procedure MethodsStored Procedure Methods
Select Stored Procedure from listSelect Stored Procedure from list Generated from login used for the VDirGenerated from login used for the VDir
Choose Web Method nameChoose Web Method name Select Output Formatting Select Output Formatting
RAW or NESTEDRAW or NESTED
Select Response Type Select Response Type XML ObjectsXML Objects Dataset ObjectsDataset Objects Single DatasetSingle Dataset
Web Service CreationWeb Service Creation
demodemo
Response TypesResponse Types
All Responses are XML / SOAPAll Responses are XML / SOAP Response Type dictates what Visual Response Type dictates what Visual
Studio.NET De-Serializes the XML intoStudio.NET De-Serializes the XML into Other clients (Microsoft SOAP Toolkit) will Other clients (Microsoft SOAP Toolkit) will
just see XMLjust see XML
Methods mapping to XML Templates Methods mapping to XML Templates have a fixed return typehave a fixed return type XML ObjectsXML Objects
XML Objects ResponsesXML Objects Responses
Visual Studio.NET recognizes an “array Visual Studio.NET recognizes an “array of objects”of objects”
Each item in the array is de-serialized Each item in the array is de-serialized into an objectinto an object XMLElement - DataXMLElement - Data SQLMessage – Error InformationSQLMessage – Error Information
Templates MUST use this response typeTemplates MUST use this response type
Dataset Objects ResponsesDataset Objects Responses
Visual Studio.NET recognizes an “array Visual Studio.NET recognizes an “array of dataset objects”of dataset objects”
Each item in the array is de-serialized Each item in the array is de-serialized into an objectinto an object Dataset - DataDataset - Data SQLMessage – Error InformationSQLMessage – Error Information
Only for Stored ProceduresOnly for Stored Procedures
SQLMessageSQLMessage
Conveys Error informationConveys Error information Object Contains the following:Object Contains the following:
Created directly from SQL Server Error Created directly from SQL Server Error MessagesMessages
ClassClassLine NumberLine NumberMessageMessageNumberNumber
ProcedureProcedureServerServerSourceSourceStateState
Single Dataset ResponsesSingle Dataset Responses
Visual Studio.NET recognizes a DatasetVisual Studio.NET recognizes a Dataset Retrieve results of a Stored Procedure Retrieve results of a Stored Procedure
and load into a Dataset in 1 line of code!and load into a Dataset in 1 line of code!Dim Service As New MyHost.MyWebService()Dim Service As New MyHost.MyWebService()
Dim ds As New System.Data.DataSet() Dim ds As New System.Data.DataSet()
Dim retval As IntegerDim retval As Integer
ds = Service.GetCustomerInfo(“ANTON”, retval)ds = Service.GetCustomerInfo(“ANTON”, retval)
Single Dataset Response Single Dataset Response LimitationsLimitations No Error InformationNo Error Information
Either a dataset comes back or it doesn’t, Either a dataset comes back or it doesn’t, no other messagesno other messages
Single Result Sets OnlySingle Result Sets Only Use Dataset Objects mode for multiple Use Dataset Objects mode for multiple
result setsresult sets
Visual Studio.NET Visual Studio.NET IntegrationIntegration SQLXML 3.0 Web Services designed for SQLXML 3.0 Web Services designed for
Visual Studio.NETVisual Studio.NET In a Visual Studio.NET Project, “Add In a Visual Studio.NET Project, “Add
Web Reference” to your Web ServiceWeb Reference” to your Web Service Proxy classes generated for your methodsProxy classes generated for your methods Forget that you are not accessing local Forget that you are not accessing local
informationinformation Visual Studio.NET takes care of the SOAP Visual Studio.NET takes care of the SOAP
messaging and XML serializationmessaging and XML serialization Intellisence recognizes SPs and Intellisence recognizes SPs and
Templates and their parametersTemplates and their parameters
Visual Studio.NETVisual Studio.NETWeb Service ClientWeb Service Client
demodemo
Visual Studio.NETVisual Studio.NETGotchasGotchas Value-Typed ParametersValue-Typed Parameters
No NULL valuesNo NULL values No Missing/Empty ParametersNo Missing/Empty Parameters
Value-Typed Return ValuesValue-Typed Return Values No NULL ValuesNo NULL Values
Data Munging in Dataset Only ModeData Munging in Dataset Only Mode Special Characters in Table NamesSpecial Characters in Table Names
Call to ActionCall to Action
Web Services ToolkitWeb Services Toolkit Download fromDownload from
http://www.microsoft.com/sql/techinfo/xmlhttp://www.microsoft.com/sql/techinfo/xml
Turn your SQL Server into a Web Turn your SQL Server into a Web Service Today!Service Today!
Let us know what your thinkLet us know what your think
Additional ResourcesAdditional Resources Web pageWeb page
http://www.microsoft.com/sql/techinfo/xml/http://www.microsoft.com/sql/techinfo/xml/ Download SQLXML releases at:Download SQLXML releases at:
http://msdn.microsoft.com/sqlxml/http://msdn.microsoft.com/sqlxml/ Contact usContact us
PSSPSS news:microsoft.public.sqlserver.xmlnews:microsoft.public.sqlserver.xml Email usEmail us
DocumentationDocumentation SQL Server 2000 Documentation (Books Online)SQL Server 2000 Documentation (Books Online) Web Release documentationWeb Release documentation BooksBooks
Books About SQLXMLBooks About SQLXML
““Professional XML Databases”Professional XML Databases”Various; Wrox Press; December, 2000Various; Wrox Press; December, 2000
““Scripting XML and WML for Microsoft SQL Server Scripting XML and WML for Microsoft SQL Server 2000”, Tobias Martinsson; John Wiley & Sons; 2000”, Tobias Martinsson; John Wiley & Sons; January, 2001January, 2001
““Programming Microsoft SQL Server 2000 with XML”Programming Microsoft SQL Server 2000 with XML”Graeme Malcolm; Microsoft Press; June, 2001Graeme Malcolm; Microsoft Press; June, 2001
““Professional SQL Server 2000 XML”Professional SQL Server 2000 XML”Various; Wrox Press; June, 2001Various; Wrox Press; June, 2001
““XML and SQL Server 2000”XML and SQL Server 2000”John Griffin; New Riders Pub; July, 2001John Griffin; New Riders Pub; July, 2001
““Working With Microsoft SQL Server and XML”Working With Microsoft SQL Server and XML”Sams Pub; January, 2002Sams Pub; January, 2002
Resources from Microsoft PressResources from Microsoft Press
For more information please visit the TechEd Bookshop.For more information please visit the TechEd Bookshop.www.microsoft.com/mspresswww.microsoft.com/mspress
SQL & XML
Don’t forget to complete the Don’t forget to complete the on-line Session Feedback form on-line Session Feedback form on the Attendee Web siteon the Attendee Web site
https://web.mseventseurope.com/teched/https://web.mseventseurope.com/teched/