DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program...

33
DAT 330 DAT 330 Building Web Services Building Web Services with SQL Server and with SQL Server and SQLXML 3.0 SQLXML 3.0 Alexander Vaschillo Alexander Vaschillo Lead Program Manager Lead Program Manager WebData XML Group WebData XML Group Microsoft Corporation Microsoft Corporation

Transcript of DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program...

Page 1: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 2: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft 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

Page 3: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 4: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 5: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 6: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 7: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 8: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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!

Page 9: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 10: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 11: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 12: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 13: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 14: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 15: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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…

Page 16: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 17: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 18: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

Web Service CreationWeb Service Creation

demodemo

Page 19: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 20: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 21: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 22: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 23: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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)

Page 24: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 25: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 26: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

Visual Studio.NETVisual Studio.NETWeb Service ClientWeb Service Client

demodemo

Page 27: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 28: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 29: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 30: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 31: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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

Page 32: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

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/

Page 33: DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.