Contents Overview 1 Lab 8.1: Building B2B Services 19 Using SQL Server 2000: Internet and Overview of BizTalk Server 2000 44 Lab 8.2: Creating Business Document Specifications Using
Trang 1Contents
Overview 1
Lab 8.1: Building B2B Services 19
Using SQL Server 2000: Internet and
Overview of BizTalk Server 2000 44
Lab 8.2: Creating Business Document
Specifications Using BizTalk Editor 52
Using BizTalk Server 2000 56
Lab 8.3: Creating Transformation Maps
Lab 8.4: Creating Business Document
Specifications Using BizTalk Orchestration
Designer 77
Review 86
Module 8: Exchanging Business Data
Trang 2to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property
2001 Microsoft Corporation All rights reserved
Microsoft, Active Directory, ActiveX, BizTalk Server, FoxPro, FrontPage, Hotmail, Jscript, Outlook, PowerPoint, Visio, Visual Basic, Visual C#, Visual C++, Visual Studio, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries
Other product and company names mentioned herein may be the trademarks of their respective owners
Trang 3Instructor Notes
This module focuses on data exchange formats and how to exchange data between diverse systems The module covers Extensible Markup Language (XML) and explains it as the most ideal and universal format for exchanging business data The module also goes into details about how XML, as an industry standard, is supported by Microsoft Specific products covered here are Microsoft® SQL Server™ 2000 and Microsoft BizTalk™ Server 2000
After completing this module, students will be able to:
Describe the common types of data exchanged as part of business (B2B) solutions
business-to- Identify the advantages of using XML as a data-interchange format
Explain the purpose of XML schemas
Describe how business documents can be converted between grammars by using Extensible Stylesheet Language Transforms (XSLT)
Identify the features in SQL Server 2000 that make it Web enabled
Identify the role of the Microsoft BizTalk Framework
Describe the main parts of a BizTalk message
Explain how to set up mappings between BizTalk document types
Describe how BizTalk documents are sent, received, and routed
Materials and Preparation
This section provides the materials and preparation tasks that you need to teach this module
Required Materials
To teach this module, you need the following materials:
Microsoft PowerPoint® file 2260A_8.ppt
Module 8, “Exchanging Business Data”
Lab 8.1, “Building B2B Services”
Lab 8.2, “Creating Business Document Specifications Using BizTalk Editor”
Lab 8.3, “Creating Transformation Maps Using BizTalk Mapper”
Lab 8.4, “Creating Business Document Specifications Using BizTalk Orchestration Designer”
Preparation Tasks
To prepare for this module, you should:
Read all of the materials for this module
Complete the labs
Presentation:
80 Minutes
Labs:
95 Minutes
Trang 4Module Strategy
Use the following strategy to present this module:
Exchanging Data Ensure that the students understand the basic concepts and issues that come
up with exchanging data between organizations Outline the different formats available for data exchange, and conclude that XML is the format that will be used in modern B2B solutions.Stress the advantages of using XML for this type of solution
Cover the example of the Purchase Order as described in this section because this will help the students design their own purchase order in Lab 8.2, “Creating Business Document Specifications Using BizTalk Editor.”
Manipulating XML
It is fundamental to this module that the students understand the different mechanisms that are available to manipulate XML structures The focus of this section is manipulating XML on the server for B2B purposes Describe the mechanisms such as XSLT and the Document Object Model (DOM), but keep the context in which you discuss these technologies in the B2B area Do not discuss using XSLT for display purposes because this is not relevant here
Lab 8.1, “Building B2B Services”
This lab prepares the foundation for a B2B procurement solution It involves creating Web sites and message queues and compiling Component Object Model (COM) components The students might find this lab easy to complete because they may have carried out all or most of these tasks at their workplace before
Using SQL Server 2000: Internet and XML Support Discuss SQL Server 2000 Internet and XML support features Do not go into any more detail about SQL Server 2000 than what is covered here The important features of SQL Server are XML support and the support for accessing SQL Server by using the Hypertext Transfer Protocol (HTTP) Both of these are new features of SQL Server 2000 and are major contributions to its status as a Microsoft NET-enabled Relational Database Management System (RDBMS)
Introducing BizTalk Describe the BizTalk initiatives It is critical that the students understand the concept of the BizTalk Framework and initiatives because they lay the groundwork for understanding how businesses can exchange data in an open, extensible manner This section must be used to set the stage for discussing the BizTalk-compliant exchange of data Do not discuss BizTalk Server 2000 or its functionality in any detail in this section BizTalk Server 2000 is covered in detail in the next section
Overview of BizTalk Server 2000 Describe the constituent parts of BizTalk Server 2000 at a high level Introduce the services and components of BizTalk Server 2000 Do not go into any more detail than what is provided in this section because some of the components and services are discussed in more detail (and in a B2B context) in the next section
Trang 5Lab 8.2, “Creating Business Document Specifications Using BizTalk Editor”
In this lab, the students will use BizTalk Editor to complete a partially filled document specification You must tell the students that in the real world, they would have to create the whole specification from scratch
Building a specification from scratch would be very repetitive in terms of lab instructions Therefore, a partially filled specification has been provided The instructions are step by step, and the students should find them clear and easy to follow However, it is likely that this is the first time that many
of them are using BizTalk Editor
Using BizTalk Server 2000 Discuss in detail the services and components of BizTalk Server 2000 Begin with a discussion of the services provided, and then overview each of its components Taking your lead from the topics in this module, delve into more depth about each of the components, such as BizTalk Editor, BizTalk Mapper, and BizTalk Orchestration Designer
Conclude this section with a discussion of BizTalk Orchestration and integration with existing Electronic Data Interchange (EDI) systems
Lab 8.3, “Creating Transformation Maps Using BizTalk Mapper”
In this lab, students will create XSLT maps by using BizTalk Mapper They will use the document specifications that they created in the previous lab The instructions are step by step, and the students should find them clear and easy to follow However, it is likely this is the first time that many of them are using BizTalk Mapper
Lab 8.4, “Creating Business Document Specifications Using BizTalk Orchestration Designer”
In this lab, students will implement BizTalk Orchestration from the perspective of the business analyst and the developer They will use BizTalk Orchestration Designer to synchronize all of the tasks that they have
undertaken in the previous three labs
The instructions are step by step, and the students should find them clear and easy to follow However, it is likely that this is the first time that many
of them are using BizTalk Orchestration Designer
Trang 7Overview of BizTalk Server 2000
Using BizTalk Server 2000
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
To exchange business data between applications, you must carefully choose the format of the data Although a variety of formats exist, the Extensible Markup Language (XML) has emerged as the most ideal and universal format for data exchange
In this module, you will learn how XML can be used to exchange information and how XML documents can be manipulated, validated, and transformed Also, you will be introduced to the Microsoft® BizTalk™ Framework, an important development that defines the next generation of business-to-business (B2B) solutions You will learn about the role of and the need for the BizTalk Framework and examine the structure of BizTalk messages and schemas Finally, you will learn about the functionality and tools provided with Microsoft BizTalk Server 2000
After completing this module, you will be able to:
Describe the common types of data exchanged as part of B2B solutions
Identify the advantages of using XML as a data-interchange format
Explain the purpose of XML schemas
Describe how business documents can be converted from one grammar to another by using Extensible Stylesheet Language Transforms (XSLT)
Identify the features in Microsoft SQL Server™ 2000 that make it Web enabled
Identify the role of the BizTalk Framework
Describe the main parts of a BizTalk message
Explain how to set up mappings between BizTalk document types
Describe how BizTalk documents are sent, received, and routed
thought must be given to the
format of the data
Trang 8Exchanging Data
Types of Business Documents
Data-Exchange Formats
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Business data comes in a variety of formats This section examines the types of business data that can be exchanged between applications and discusses the options for how this data can be represented
Trang 9Types of Business Documents
Examples of Document Types
The details in a purchase order can be grouped into:
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Many different types of documents are exchanged between applications and organizations in e-business
Examples of Document Types
Some of the document types that are used in e-business data exchange are as follows:
Examining a Sample Document Type: Purchase Orders
A purchase order usually has header information at the beginning, which specifies the following details:
Purchase order issue date
Buyer reference number
Supplier reference number
Details of the buyer, such as name and address
Tax details, such as tax percentage, location (for sales tax calculations), tax code, taxable amount, and total tax payable
Many different types of
documents are exchanged
between applications and
organizations in e-business
Trang 10A purchase order also contains shipment details, such as the following:
Delivery charge details
Whether partial shipment is allowed
Requested delivery date
Details of the ship-to party, such as the order contact name and address, and the receiving contact name and address
Transport type, for example, “road” or “air”
The rest of the purchase order consists of the list of items being purchased For each item, the following details are typically provided:
Item number in the purchase order (1, 2, 3, and so on)
Supplier part number
Quantity required, including unit of measurement
Buyer's expected unit price
Final recipient for this order item
Requested delivery date
Any special handling required for this item, such as fragile, hazardous, and
so on
Finally, the total cost of the order is usually specified at the bottom of the purchase order
Trang 11*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Business information can be formatted in a number of ways in B2B solutions:
Electronic Data Interchange (EDI)
Custom data format
XML
EDI
Electronic Data Interchange emerged in the 1970s as an electronic standard for the exchange of business information There are several EDI standards that define the format of messages for a typical business transaction Perhaps the most notable EDI standard is EDIFACT (EDI for Administration, Commerce, and Transport), defined by the United Nations For more information, see http://www.unece.org/trade/untdid/welcom1.htm
EDI is used by companies for automated transactions with trading partners However, EDI has certain limitations:
EDI is expensive and relatively complex and has therefore been limited to larger businesses and their partners
Both the sender and receiver of EDI messages have to agree on the message format and adopt a tailored software program to map between their two types of datasets Whenever a new sender or receiver is added, another translation program is needed by the new trading partner to understand the data formats used by the participants The number of translation programs required increases with the increase in the number of trading partners
EDI handles business transactions only
It does not address the wider business needs of e-commerce, such as marketing, customer research, and customer loyalty programs
Topic Objective
To discuss the various
formats available for data
Trang 12Custom Data Format
Organizations may agree upon a custom data format to be used when exchanging information electronically The custom data format might be based
on text files, with the use of commas or tabs to identify different pieces of information Alternatively, a binary message structure might be used for increased data compression and processing speed
Whether a text format or a binary format is used, the limitations of custom data formats are clear The sender and receiver of the information need to agree on the structure of these custom data formats If the format changes, the sender and receiver must remain in rigid synchronization to ensure that they are both using the latest message structure that has been agreed upon Furthermore, because the data format is a private agreement between two trading partners, it makes it difficult for new trading partners to participate in information exchange Trading partners can interpret messages only if they are aware of the data format being used, and therefore, they need to be notified whenever the format changes Each trading partner will need translation software to convert their in-house data formats into the agreed-upon custom data format that is used when exchanging information with other trading partners
XML
XML is a text-based language that provides a universal format for describing data By using XML, you can retrieve data from legacy applications, relational databases, object-oriented databases, or other applications in the business The data can then be represented in a universal format such as XML, which can be transmitted to any other system Because XML documents preserve the meaning and the context of the data, any application can use this data in an efficient and useful manner
XML is the language that is best suited to e-business, and it will play a key role
in the adoption and expansion of online trading between businesses in the future Several key initiatives, standards, and toolsets have already been established, thereby making it easier for companies to conduct document-based transactions by using the Web
Trang 13Manipulating XML
Handling Multiple XML Formats
Transforming XML on the Server
Defining XML Grammar
Validating XML Documents
Causes of Invalid XML Documents
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
XML is an ideal format for e-business communication Because XML is descriptive in nature and uses open standards, it is easy for organizations to exchange XML documents in response to business activities
This section discusses how to manipulate XML documents and how to transform XML documents into different formats You will see how to create schemas to specify the format of an XML document and how to use these schemas to validate the content of an XML document
Trang 14Handling Multiple XML Formats
Issues with XML
The Need for Standards
Transforming XML Document Types
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
XML resolves many of the difficulties encountered when dealing with disparate data, including:
XML documents can be routed between trading partners, with each of them being able to extract, interpret, and augment the information in the
The use of XML raises its own issues:
Who defines the allowed elements and attributes in an XML document?
How do you describe your choice of element names and attribute names so that other organizations know about the format of your XML documents?
How and where do you publish your document description to make it readily available to other organizations?
Where do you look to find out about the XML data formats defined by others?
Because XML is inherently an extensible markup language, different organizations can (and often do) define their own XML data formats
It is possible to define a Document Type Definition (DTD) or an XML Schema
to describe the allowed elements and attributes in an XML document These concepts are covered in Defining XML Grammar in this module
use for exchanging business
documents over the
Internet
Trang 15The Need for Standards
It would be beneficial for all commercial organizations if a set of standard XML data formats was defined and used consistently in e-business For example, there is no need for every company to define its own data formats for common document types such as invoices, purchase orders, and shipping schedules The benefits of defining common data formats can be summarized as follows:
Organizations do not need to invest time and effort defining (and maintaining) their own data formats
There is greater consistency between applications because they use a common data format
The common data format can be published centrally, thereby relieving organizations from this responsibility
The BizTalk initiative includes a Schema Library, in which many standard document types are held in a centralized repository Organizations can use these document types directly, or they can define their own schema and add
it to the library The BizTalk initiative is discussed later in this module
Transforming XML Document Types
Although a common set of standard document types is beneficial, it is by no means essential The self-describing nature of XML elements and attributes makes it possible for an application to receive an XML document in any format All that is needed by the receiving application to parse the data is a description
of the data format being used so that the application knows how to handle the data Indeed, it is quite feasible and straightforward to aggregate XML data in a variety of formats and transform the data into a new format The next topic discusses mechanisms for transforming XML data
Note
Trang 16Transforming XML on the Server
Techniques for Transforming XML on the Server
pay="91000"/>
…
</staff>
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Because each business uses different formats of XML for common business documents, you might often need to transform an XML document into a different format on the server Such situations, in which XML transformation is required, are as follows:
An XML document from a trading partner might have to be transformed into another XML format for use in your system
An XML document might contain sensitive information that must be stripped out before passing the document on to a trading partner
An XML document might need to be transformed into Hypertext Markup Language (HTML) so that it can be displayed in a browser that does not support XML
Techniques for Transforming XML on the Server
You can transform XML data at the server by using the following techniques:
Extensible Stylesheet Language Transforms (XSLT)
Document Object Model (DOM)
As described in the rest of this topic, both techniques have their uses They can also be combined into one solution
Topic Objective
To discuss the techniques
that can be used for
transforming XML on the
server
Lead-in
Because each business
uses different formats of
XML for common business
documents, you might often
need to transform an XML
document into a different
format on the server
Trang 17Transformations Using XSLT
An XSLT style sheet can be used to convert an XML document from one grammar to an XML document in another grammar By using an XSLT style sheet, you can perform the following transformations on an XML document:
Filter out unwanted elements and attributes For example, you can filter out elements such as <WholesalePrice> and
<NumberInStock> in an XML document
Sort elements For example, you can sort <Product> elements in increasing price order Alternatively, you can sort <Product> elements such that those having a
<Perishable> child element appear first
Add new elements, attributes, and other XML content to a document For example, a bookstore might receive an order for a book from one of its customers If the book is not in stock, the bookstore can issue an order to the publisher At this stage, the bookstore can add extra elements such as
<BookStoreID> and <DeliveryDate> to the XML document
Transform an XML document into an entirely new format For example, an organization might receive an XML document from one of its customers, transform it into a completely new XML format, and then pass the new-format XML document on to one of its suppliers
Transformations Using the DOM
XSLT style sheets are powerful, but some transformations are better achieved
by using the DOM in server-side code or script The DOM defines a programming interface that allows you to write programs or script to read, modify, extend, or delete data in an XML document Some examples in which using the DOM is more appropriate than using XSLT for transforming and manipulating XML data are as follows:
Performing complex processing on XML data
It is often appropriate to apply the processing power of languages, such as Microsoft Visual Basic® and VBScript, to manipulate XML data The manipulation can be achieved by using the DOM
Performing calculations with XML data
It is often easier to perform calculations on your XML data values by using the DOM rather than XSLT For example, you might wish to calculate the number of <Item> elements in a <PurchaseOrder> These calculations can
be achieved easily by using the DOM
Writing style sheets and using the DOM is quite complex BizTalk Server 2000 simplifies these tasks for you
Note
Trang 18Defining XML Grammar
DTDs
XML Schemas
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
One of the key goals of XML is to facilitate the open exchange of information between applications and organizations This is possible only if the structure and the format of these XML documents is defined and published for others to read and understand
The two ways to define the expected grammar of an XML document are by using:
An example of a DTD is as follows:
<!ELEMENT Order (OrderItem+) >
<!ELEMENT OrderItem (Quantity, UnitPrice) >
<!ATTLIST OrderItem ProductID CDATA #REQUIRED >
<!ELEMENT Quantity (#PCDATA) >
<!ELEMENT UnitPrice (#PCDATA) >
The preceding DTD document defines the following rules:
The XML document has an element named <Order>, which contains one or more <OrderItem> child elements
Each <OrderItem> has one <Quantity> child element, followed by one
<UnitPrice> child element
Each <OrderItem> also has an attribute named ProductID, which is mandatory
There are two ways to
define the expected
grammar of an XML
document
Trang 19The <Quantity> element (defined in <OrderItem>) is simple text
The <UnitPrice> element (defined in <OrderItem>) is simple text
Despite the apparent simplicity of DTDs and the fact that they are a mature standard in W3C, they have several weaknesses, including:
DTDs do not allow data types to be specified for elements or attributes
DTDs have a closed model
An XML document specified by a DTD cannot grow to contain additional information in the future because the extra information is not specified in the DTD
DTDs do not support XML namespaces
Namespaces are required for demarcating XML documents from different organizations and standards bodies
DTDs apply to an entire XML document
It is not possible to apply DTDs to individual XML elements or specific portions of the document
Trang 20The following sample schema corresponds to the DTD example shown above This schema complies with the XDR schema syntax Notice that the schema is itself a well-formed XML document The root element is <Schema> The
<Schema> element must always be written exactly as shown in the following sample code:
<?xml version="1.0"?>
<Schema name="mySchema"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml-datatypes"> <ElementType name="Quantity" content="textOnly"
model="closed" dt:type="int" />
<ElementType name="UnitPrice" content="textOnly"
model="closed" dt:type="float" />
<AttributeType name="ProductID" dt:type="string" />
<ElementType name="OrderItem" content="eltOnly"
model="closed" order="seq">
<element type="Quantity" minOccurs="1" maxOccurs="1" /> <element type="UnitPrice" minOccurs="1" maxOccurs="1" /> <attribute type="ProductID" required="yes" />
</ElementType>
<ElementType name="Order" content="eltOnly" model="closed"> <element type="OrderItem" minOccurs="1" maxOccurs="*" /> </ElementType>
</Schema>
The preceding schema defines the following rules:
The XML document can contain <Quantity> elements, which consist of only text (that is, no child elements)
<Quantity> elements have an integer data type
The XML document can also contain <UnitPrice> elements, which consist
of only text
<UnitPrice> elements have a float data type
The XML document can contain multiple instances of the ProductID attribute, which contains a string data type
The <OrderItem> element can consist of one <Quantity> child element, one
<UnitPrice> child element, and a mandatory ProductID attribute
The <Order> element can consist of one or more <OrderItem> elements and
no stand-alone textual content
Schemas are undoubtedly much more verbose than DTDs, but they provide a much richer and more rigorous definition of the content required in an XML document Schemas are soon expected to become the standard means of defining XML grammars
Trang 21Validating XML Documents
Well-Formed vs Valid XML Documents
XML
rules defined in the XML schema/DTD attached to the document
Applying an XML Schema to an XML Document
<! My XML document, with an XML Schema applied >
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
To use XML as the means of describing data, the XML document must at least adhere to the basic syntax of XML In addition, it is often the case that the structure of the document must be validated against a set of rules that is specific
to the document type
Well-Formed Documents
A well-formed XML document follows the basic syntax rules of XML For example, there must be a single root element, and each opening tag must have a corresponding closing tag Furthermore, XML is case sensitive, and therefore, opening tags and closing tags must use the same case Elements may be nested within other elements, but this must be done in a conformed, non-overlapping manner In addition, all attribute values must be enclosed in quotes, and an element cannot contain two or more attributes with the same name
Trang 22Applying an XML Schema to an XML Document
To apply an XML schema to a static XML document, you must add a namespace declaration to an element in your XML document, as shown in the following example:
<! My XML document, with an XML Schema applied >
When the document is loaded into a validating parser, the parser also loads the XML schema so that validation can take place
Usually, an XML schema is applied to the root element of the XML document
so that it defines the grammar for the entire document However, it is also possible to apply an XML schema to any element in an XML document to define the grammar for a portion of that document
Trang 23Causes of Invalid XML Documents
Invalid documents can arise because of:
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
There are several situations that might give rise to an invalid XML document being delivered to an application Some of the possibilities include:
Malicious Alteration of XML Data
When an XML document is sent from one application to another, the possibility exists that the document might be tampered with in transit Content might be maliciously added, modified, or deleted in the document Therefore, the receiving application must be capable of validating the XML data as it is received, rather than assuming that if the XML data was valid when it was sent,
it is still valid when it is received
It is advisable that both the sender of the document validates the data by applying the schema before it is sent and that the receiver validates the documents as it is received to minimize the risk that data has been tampered with in transit
Topic Objective
To discuss the causes of
invalid XML documents
Lead-in
There are several reasons
why invalid XML documents
get created in the first place
Note
Trang 24Misinterpretation of XML schema
XML schemas perform a dual role In addition to enabling validation to take place when an XML document is loaded into the parser, they also act as a source of documentation for application developers by telling them what structure of XML to build XML schemas can be quite complex to read and understand, and the developer might misinterpret the grammar rules and build
an invalid XML document by mistake
Trang 25Lab 8.1: Building B2B Services
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Objective
After completing this lab, you will be able to:
Prepare a message queue and configure Web sites for use in a B2B solution
Create and register Component Object Model (COM) components and Microsoft Windows® Scripting Components that can be used in a B2B solution
Scenario
LitWare Books plans to implement a B2B automated procurement system that enables their employees to order new books and replenish the stocks for resale through their business-to-consumer (B2C) Web site The business managers at LitWare Books have defined that:
Any purchase order request for a total value of 1,000 dollars or less can be automatically approved
Any purchase order request with a total value of more than 1,000 dollars must not be automatically approved
Topic Objective
To introduce the lab
Lead-in
In this lab, you will create a
message queue and a Web
site for starting the
procurement process of
submitting purchase order
requests You will also
create and register COM
components and Microsoft
Windows Scripting
Components that can be
used in a B2B solution
Trang 26You will create a message queue and a Web site for starting the procurement process of submitting purchase order requests You will also create a drop folder for approved purchase order requests You will then create and register a COM component that determines the total value of a purchase order request Finally, you will create and register a Windows Scripting Component that determines whether a purchase order request must be approved automatically
Starter and Solution Files
There are starter files associated with this lab The starter files are in the
<install folder>\Labs\Lab081\Starter folder There are no solution files
associated with this lab
Estimated time to complete this lab: 15 minutes
Trang 27Exercise 1
Creating a Message Queue
In this exercise, you will create a message queue for the buyer organization, LitWare Books The queue will be configured to wait for a purchase order request
To create the purchase order request queue
1 On the Start menu, point to Programs, point to Administrative Tools, and then click Computer Management
2 In the Tree pane, expand Services and Applications, expand Message Queuing, and then click Private Queues
3 On the Action menu, point to New, and then click Private Queue
The Queue Name dialog box appears
4 In the Name text box, type ReceivePOReq
5 Select the Transactional check box to make the queue transactional, and then click OK
Leave the Computer Management console open because you will use it in the next exercise You have created a queue, which you will use in later in this lab
Trang 28Exercise 2
Creating a Web Site
In this exercise, you will create a procurement Web site for submitting purchase order requests by:
Creating two folders and copying the Active Server Pages (ASP) files and the XML files supplied to you in one of the folders
Configuring one of the folders as a Web site
To create the required folders
1 Open Windows Explorer
2 Under the \InetPub\WWWRoot\ folder, create a folder called
ASPSubmitPO
3 Under the root of your C: drive, create a folder called Buyer
To copy the files into the ASPSubmitPO folder
• Copy all of the files from the <install folder>\Labs\Lab081\Starter folder to
the \InetPub\WWWRoot\ASPSubmitPO folder that you created earlier
To create a procurement Web site
1 Switch to the Computer Management console
2 In the Tree pane, under Services and Applications, expand Internet Information Services
3 Click Default Web Site
4 On the Action menu, point to New, and then click Virtual Directory
5 On the Welcome to the Virtual Directory Creation Wizard page, click Next
6 On the Virtual Directory Alias page, in the Alias text box, type ASPSubmitPO and then click Next
7 On the Web Site Content Directory page, click Browse
8 Browse to the \InetPub\WWWRoot\ASPSubmitPO folder, and then click
OK
9 Click Next
10 On the Access Permissions page, do not change any default values, and then click Next
11 Click Finish to close the Virtual Directory Creation Wizard
You have now created the Web site that will be used to submit purchase order requests to the B2B procurement solution
Trang 29Exercise 3
Creating and Registering COM Components
In this exercise, you will create and register a COM component that provides application services required to implement the LitWare Books scenario In particular, you will create and register a COM component that determines the total value of the purchase order request In addition, you will register a Windows Scripting Component that sends the approval status in the form of a message box and writes the purchase order request to a local file location if it is approved
To create the PORequest component
1 On the Start menu, point to Programs, point to Microsoft Visual Studio 6.0, and then click Microsoft Visual Basic 6.0
2 Click the Existing tab, and browse to the
\InetPub\WWWRoot\ASPSubmitPO folder
3 Select LitwareComponents.vbp
4 Click Open
5 Review the code in the PORequest class module
6 On the File menu, click Make PORequest.dll
7 Click OK
8 Close Visual Basic
When prompted to save changes to the project, click No
To register the Windows scripting component
1 Open Windows Explorer
2 Browse to the \InetPub\WWWRoot\ASPSubmitPO folder
3 Select PORequestApproval.wsc
4 Right-click the file, and then choose Open
5 Review the definition of the component, and then close the file
6 In Windows Explorer, on the File menu, click Register
A message box appears, notifying you that the component was successfully registered
You have now created and registered the components that will be used for the LitWare Books B2B procurement solution You will see how these components are incorporated into the B2B procurement solution in Lab 8.4, “Creating Business Document Specifications Using BizTalk Orchestration Designer.”
Trang 30Using SQL Server 2000: Internet and XML Support
IIS Virtual Directory
Retrieving XML from SQL Server: FOR XML Clause
Writing Queries Using OPENXML Function
Accessing SQL Server Using HTTP
Demonstration: Accessing SQL Server Using HTTP
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
SQL Server 2000 is the primary database engine used in any Microsoft-based e-business application SQL Server 2000 introduces new features that support XML functionality and the combination of these features makes
SQL Server 2000 an XML-enabled database server These new features include:
The ability to access SQL Server by using Hypertext Transfer Protocol (HTTP)
Support for XDR schemas and the ability to specify queries against these schemas
The ability to retrieve XML data by using the SELECT statement and the FOR XML clause
The ability to write XML data by using OPENXML rowset provider
This section examines the SQL Server 2000 features that support XML and the Internet
primary database engine
used in any Microsoft-based
e-business application
Trang 31IIS Virtual Directory
Using IIS Virtual Directory Management for SQL Server Utility
to SQL Server
Using Virtual Names
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
Before accessing a SQL Server 2000 database by using HTTP, you must set up
an appropriate virtual directory associated with the database The Internet Information Services (IIS) Virtual Directory Management for SQL Server utility is provided with SQL Server 2000 to create a virtual root specific to SQL Server 2000
Using IIS Virtual Directory Management for SQL Server Utility
The IIS Virtual Directory Management for SQL Server utility can be used to define and register a new virtual directory on the computer running IIS This utility instructs IIS to create an association between the new virtual directory and an instance of SQL Server
The name of the IIS server and the virtual directory must be specified as part of
a URL that accesses the SQL Server database The information in the virtual directory (including logon, password, and access permissions) is used to establish a connection to a specific database and execute a query
Using Virtual Names
You can access the SQL Server 2000 virtual directory in various ways, including:
Specifying a SQL query in a URL
Specifying a template file in a URL
Specifying an XML Path (XPath) language query in a URL
XPath is the standard navigation language used to query XML documents
Topic Objective
To discuss how to use the
IIS Virtual Directory
Management for SQL
Server utility to create the
virtual directory for SQL
Trang 32To access objects, virtual names are used in the URLs These concepts are explained in greater detail later in this module, but you must be aware that virtual names must be configured with the IIS Virtual Directory Management for SQL Server utility before accessing the virtual directory
There are three different types of virtual names:
Dbobject—These are associated with SQL Server objects, such as tables
Trang 33Retrieving XML from SQL Server: FOR XML Clause
Use the FOR XML clause in a SELECT statement to retrieve data in XML format
Specify one of the following modes in the FOR XML clause:
RAW
AUTO
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
In addition to supporting URL access, SQL Server 2000 has powerful capabilities that can be used for handling XML data You can execute SQL queries against existing relational databases to return results as XML documents rather than as standard rowsets You can also have SQL Server present hierarchical XML data in traditional rowset format (rows and columns)
To retrieve results directly, use the FOR XML clause of the SELECT statement and in the FOR XML clause, specify one of these XML modes:
AUTO
EXPLICIT
RAW Mode
RAW mode transforms each row in the query result set into an XML element
with the generic identifier row Each column value that is not NULL is mapped
to an attribute of the XML element in which the attribute name is the same as the column name
This query returns customer and order information RAW mode is specified in the FOR XML clause:
SELECT Customers.CustomerID, Orders.OrderID, Orders.OrderDate FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID ORDER BY Customers.CustomerID
Trang 34The following is the partial result in XML returned by the SQL query:
<row CustomerID="ALFKI" OrderID="10643" 25T00:00:00"/>
OrderDate="1997-08-<row CustomerID="ANATR" OrderID="10308" 18T00:00:00"/>
OrderDate="1996-09-<row CustomerID="ANATR" OrderID="10625" 08T00:00:00"/>
OrderDate="1997-08-<row CustomerID="AROUT" OrderID="10355" 15T00:00:00"/>
option is specified, the table columns are mapped to sub-elements instead of
attributes By default, AUTO mode maps the table columns to XML attributes
The hierarchy (nesting of the elements) in the result set is based on the order of
tables that are identified by the columns that were specified in the SELECT
clause Therefore, the order in which column names are specified in the
SELECT clause is significant
The tables are identified and nested in the order in which the column names are
listed in the SELECT clause The first table referenced in the clause forms the
top element in the resulting XML document The second table referenced in the clause forms a sub-element within the top element, and so on
If a column name listed in the SELECT clause is from a table that is already identified by a previously specified column in the SELECT clause, the column
is added as an attribute of the element already created or as a sub-element if the
ELEMENTS option is specified, instead of opening a new level of hierarchy
(adding a new sub-element for that table)
The following query specifies FOR XML AUTO:
SELECT Customers.CustomerID, Orders.OrderID, Customers.ContactName
FROM Customers, Orders WHERE Customers.CustomerID = Orders.CustomerID FOR XML AUTO
The following example is the partial result in XML returned by the SQL query:
<Customers CustomerID="ALFKI" ContactName="Maria Anders"> <Orders OrderID="10643"/>
Trang 35Note that in the SELECT clause, CustomerID identifies the Customers table
Therefore, a <Customers> element is created and CustomerID is added as its attribute Next, the OrderID column name identifies the Orders table An
<Orders> element is added as a sub-element of <Customers>, and the OrderID attribute is added to the <Orders> element Now, the ContactName column identifies the Customers table, which was already identified by the CustomerID column Therefore, no new element is created Instead, ContactName is added
as an attribute to the <Customers> element that is already created
The following query specifies the ELEMENTS option Therefore, an
element-centric document is returned
SELECT Customers.CustomerID, Orders.OrderID, Customers.ContactName
FROM Customers, Orders WHERE Customers.CustomerID = Orders.CustomerID FOR XML AUTO, ELEMENTS
This is the partial result of the query:
In EXPLICIT mode, you can control the structure of the XML document
returned by the query The query must be written in a specific way so that the additional information about the expected nesting is explicitly specified as part
of the query For more information about using EXPLICIT mode, see “Using
EXPLICIT Mode” in the SQL Server Books Online
Trang 36Writing Queries Using OPENXML Function
OPENXML provides data in a rowset format, based on a hierarchical XML structure
FROM OPENXML (@idoc, '/ROOT/Customer',1) WITH (CustomerID varchar(10), ContactName varchar(20)) EXEC sp_xml_removedocument @idoc
FROM OPENXML (@idoc, '/ROOT/Customer',1) WITH (CustomerID varchar(10), ContactName varchar(20)) EXEC sp_xml_removedocument @idoc
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
OPENXML is a Transact-SQL function that provides data in a traditional
rowset format The rowset is based on a hierarchical XML structure
OPENXML is a rowset provider, which is similar to a table or a view
OPENXML allows access to XML data as if it is a relational rowset by
providing a rowset view of the internal representation of an XML document The records in the rowset can be stored in database tables (similar to the rowsets that are provided by tables and views)
OPENXML can be used in SELECT and SELECT INTO statements wherever rowset providers—such as a table, a view, or OPENROWSET—can
appear as the source
OPENROWSET is a SQL Server function that is used to query remote
database servers It accepts parameters such as connection strings and an SQL query It returns any data to the client application that the other database server
returns to the SQL Server As such, it is similar to running a SELECT
The parsed document is a tree representation of the various nodes (elements, attributes, text, comment, and so on) in the XML document
2 Pass the document handle to OPENXML, which then provides a rowset
view of the document based on the parameters passed to it
3 Call the sp_xml_removedocument system stored procedure to remove the internal representation of the XML document from the memory
Transact-SQL function that provides
data in a traditional rowset
format
Note
Trang 37The XML document in the following example consists of the <Customer>,
<Order>, and <OrderDetail> elements The OPENXML function retrieves
customer information in a two-column rowset (CustomerID and ContactName) from the XML document
DECLARE @idoc int DECLARE @doc varchar(1000) SET @doc ='
<ROOT>
<Customer CustomerID="VINET" ContactName="Paul Henriot"> <Order OrderID="10248" CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
<OrderDetail ProductID="11" Quantity="12"/>
<OrderDetail ProductID="42" Quantity="10"/>
</Order>
</Customer>
<Customer CustomerID="LILAS" ContactName="Carlos Gonzalez"> <Order OrderID="10283" CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">
<OrderDetail ProductID="72" Quantity="3"/>
</Order>
</Customer>
</ROOT>' Create an internal representation of the XML document EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
Execute a SELECT statement using OPENXML rowset provider SELECT *
FROM OPENXML (@idoc, '/ROOT/Customer',1) WITH (CustomerID varchar(10), ContactName varchar(20)) EXEC sp_xml_removedocument @idoc First, the sp_xml_preparedocument stored procedure is called to obtain a
document handle This document handle is passed to OPENXML
In the OPENXML function:
/ROOT/Customer identifies the <Customer> nodes to process
The flags parameter value is set to 1, which indicates attribute-centric
mapping
As a result, the XML attributes map to the columns in the rowset defined in
the schema declaration (in the WITH clause)
The column name values in the schema declaration match the corresponding XML attribute names
Therefore, the column pattern parameter is not specified in schema declaration
The SELECT statement retrieves all of the columns in the rowset provided
by OPENXML
Example
Trang 38The result of executing the SQL query is as follows:
CustomerID ContactName - - VINET Paul Henriot
LILAS Carlos Gonzalez
When the above SELECT statement is executed with flags set to 2,
element-centric mapping is used instead of attribute-element-centric mapping Because CustomerID and ContactName are attributes, their values for both of the customers would be returned as NULL If the <CustomerID> and
<ContactName> were sub-elements in the XML document, the element-centric mapping would retrieve their values
Result
Trang 39Accessing SQL Server Using HTTP
HTTP Access
XML Documents and Document Fragments
*****************************I LLEGAL FOR N ON -T RAINER U SE *****************************
You can access SQL Server 2000 using HTTP by:
Specifying SQL queries directly in a URL An example of this feature is as follows:
http://IISServer/nwind?sql=SELECT+*+FROM+Customers+FOR+
XML+AUTO&root=root
The FOR XML clause returns the result as an XML document instead of a
standard rowset The root parameter identifies the single, top-level element
Specifying template definitions directly in a URL
Templates are valid XML documents that contain one or more SQL statements The templates allow you to put together data to form a valid XML document, which is not necessarily the case when queries are specified directly in the URL For example:
http://IISServer/nwind?template=<ROOT+xmlns:sql=
"urn:schemas-microsoft-com:xml-sql"><sql:query>
SELECT+*+FROM+Customers+FOR+XML+AUTO</sql:query></ROOT>
Specifying template files in a URL
Writing long SQL queries in the URL can be cumbersome In addition, browsers may have limitations on the amount of text that can be entered in the URL To avoid these problems, templates can be written and stored in a file A template is a valid XML document that contains one or more SQL statements and XPath queries You can specify a template file directly in a URL, for example:
Trang 40In the preceding URL, TemplateVirtualName is the virtual name of the template that is created by using the IIS Virtual Directory Management for the SQL Server utility
Template files also enhance security by encapsulating the details of database queries from the user By storing the template file in the virtual root
directory (or its subdirectories) in which the database is registered, security can be enforced by removing the URL query-processing service on the virtual root and leaving only the SQL Server XML Internet Server Application Programming Interface (ISAPI) to process the files and return the result set
Writing XPath queries against the XDR schemas
Writing XPath queries against the mapping schemas is conceptually similar
to creating views by using the CREATE VIEW statement and writing SQL
queries against them An example of an XPath query is as follows:
http://IISServer/nwind/SchemaVirtualName/schemafile.xml/
Customer[@CustomerID="ALFKI"]
In the preceding URL, SchemaVirtualName is the virtual name of the schema type that is created by using the IIS Virtual Directory Management for SQL Server utility Customer[@CustomerID="ALFKI"] is the XPath query executed against the schemafile.xml, which is specified in the URL
Specifying database objects directly in a URL
The database objects, such as tables and views, can be specified as part of the URL, and an XPath can be specified against the database object; for example:
http://IISServer/nwind/dbobjectVirtualName/XpathQuery
In the URL, dbobjectVirtualName is the virtual name of the dbobject type that is created by using IIS Virtual Directory Management for SQL Server utility
XML Documents and Document Fragments
When you execute a template or a query with the root parameter, the result is a full XML document with a single top-level element For example, the following URL executes a template:
http://IISServer/VirtualRoot/TemplateVirutalName/
MyTemplate.xml This is a sample template file (MyTemplate.xml):
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:query>
SELECT * FROM Customers FOR XML AUTO </sql:query>
</ROOT>
The <ROOT> tag in the template provides the top-level single element for the resulting XML document