This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
The XMLOnlineCatalog sample application displays information about particular products. This sample retrieves information from the following columns in the SQL Server AdventureWorks
- CatalogDescription column of xml type in the Production.ProductModel table
- LargePhoto column in the Production.ProductPhoto table The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\XML\XmlOnlineCatalog
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.
A developer wants to retrieve XML-based descriptions of products from a Web service hosted by SQL Server.
Transact-SQL, XML, XSD, XSLT, Visual C#, and Visual Basic.
The XmlOnlineCatalog sample uses the following features of SQL Server:
| Application Area || Features |
| Overall|| XML, SQL Server-hosted Web services |
Before running this sample, make sure the following software is installed:
- SQL Server or SQL Server Express. You can obtain SQL Server Express free of charge from the SQL Server Express Download site.
- The AdventureWorks database that is available at the SQL Server Developer Web site.
- The SQL Server Database Engine samples that are available at the SQL Server Developer Web site.
- .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. For more information, see Installing the .NET Framework Documentation.
Building the Sample
If you have not already created a strong name key file, generate the key file using the following instructions.
To generate a strong name key file
- Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.-- or --Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.
- Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed. Note: To determine the folder where samples are located, click the Start* button, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.*
- At the command prompt, run the following command to generate the key file: sn -k SampleKey.snk Important: For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.
To build the sample, do the following:
Build the sample
- Ensure that the AdventureWorks sample database is installed.
- In SQL Server Management Studio, load and run the scripts\install.sql script, or run the following command at the command prompt: sqlcmd -E -I -i Scripts\install.sql This script creates the following:
- GetProductDescription stored procedure
- sql_ProductCatalog HTTP Endpoint
- In Windows Explorer, right-click the CS\XmlOnlineCatalog folder where the sample was installed, click Properties, click the Web Sharing tab, click the Share this folder option, and then click OK twice. This creates an IIS virtual folder for the sample that will enable the application to work correctly.
- Compile the application by using the provided Microsoft Visual Studio solution, or run the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt: msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\xmlonlinecatalog.sln
Running the Sample
To run the sample, do the following:
Run the sample
- Run the CS\XmlOnlineCatalog\bin\debug\XmlOnlineCatalog.exe application.
- Enter 19 for the ProductModelID value and click Show Description. For information about the format of the SOAP request, click Show Request. For information about the format of the SOAP response from SQL Server, click Show Response. For information about the XSLT file that rendered the instructions, click Show XSL. You can search the ProductModel table to find other ProductModelID values for which the catalog description XML is stored.
Removing the Sample
To remove the sample, do the following:
Remove the sample
- Open the Scripts\Cleanup.sql file by using SQL Server Management Studio and run the contents of the file. Or, run the following command at the command prompt: sqlcmd -E -I -i Scripts\cleanup.sql
Help and Information
- Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.