Microsoft KB Archive/307599

= HOW TO: Submit Orders to Microsoft BizTalk Server from Commerce Server 2000 =

Article ID: 307599

Article Last Modified on 8/5/2004

-

APPLIES TO


 * Microsoft BizTalk Server 2000 Standard Edition
 * Microsoft Commerce Server 2000 Standard Edition

-



This article was previously published under Q307599



IN THIS TASK
Summary Install a Sample Retail Site on the Computer Running Commerce Server 2000
 * Create a Purchase Order XML Schema
 * Create a Purchase Order Document Definition
 * Create the Supplier Organization
 * Create a Port to the Supplier Organization
 * Configure the Channel to the Supplier Organization
 * Configure Commerce Server to Send Purchase Orders to BizTalk Server
 * Import the Books Catalog into the Retail Site
 * Associate the Books Catalog with the BizTalk Supplier Organization
 * Create the Receive.asp page in the Root Directory of the Default Web Site
 * Test to Ensure that Purchases Completed on the Retail Site Generate Purchase Orders That Are Correctly Processed by BizTalk Server



SUMMARY
This article describes the steps to configure Commerce Server 2000 sites to submit purchase orders through BizTalk Server 2000.

NOTE: The information in this article is for users who have BizTalk Server and Commerce Server 2000 installed on the same computer.

back to the top

Install a Sample Retail Site on the Computer Running Commerce Server 2000
NOTE: If you already have a working Retail Site available on your Commerce Server Store, you can skip to the Create a Purchase Order XML Schema section of this article.
 * 1) Download and install Microsoft Commerce Server Solution Sites from:

http://download.microsoft.com/download/comserver/Trial/Evaluation/NT5/EN-US/CommerceServerSolution.exe
 * 1) After you install the Commerce Server Solution Sites, double-click the Retail.pup file in the Program Files\Microsoft Commerce Server\PuP Packages folder to unpack the Retail Site. When you double-click this file, the Commerce Server Site Packager Wizard starts. Select the Custom unpack option, and then click Next.
 * 2) Click Create a new site, and then click Next.
 * 3) When you are prompted, set the Custom unpack option to the site name Retail.
 * 4) In the Unpack Method dialog box, click Create a new site, and then click Next.
 * 5) Enter the site name Retail, and then click Next.
 * 6) In the Select Resources dialog box, click Next.
 * 7) In the Global Resource Pointers dialog box, click Next.
 * 8) In the Database Connection Strings dialog box, click Next. If you are prompted, enter the appropriate Microsoft SQL Server user name and password.
 * 9) In the Select Applications dialog box, make sure that the Retail and RetailbizDesk check boxes are selected (checked), and then click Next.
 * 10) In the Select IIS Web Sites and Virtual Directories dialog box, keep the default settings, and then click Next.
 * 11) When the Data Warehouse dialog box appears, change the name of the Data Warehouse to Data Warehouse Retail, and then click OK.
 * 12) In the Profiling dialog box, keep the default settings, click Next, and then click OK.
 * 13) When the Unpacking is complete! dialog box appears, click Finish.
 * 14) You should now be able to access your Retailbizdesk application by browsing to http://localhost/Retailbizdesk.

back to the top

Create a Purchase Order XML Schema

 * 1) Start the BizTalk Editor, click Tools, and then click Import.
 * 2) Select Well Formed XML Instance as the document type, navigate to the physical directory that houses your Retail virtual directory (Inetpub\Wwwroot\retail by default), and then select Poschema.xml.
 * 3) Add an ordernumber attribute to the document definition by right-clicking the orderform element, and then clicking New Field. Name the new attribute ordernumber.
 * 4) Click File, and then click Save to save the modified specification. Overwrite the existing file when you are prompted.
 * 5) Publish this document to the BizTalk WebDav repository by clicking File, and then clicking Store to WebDav. Store the file to WebDav with the name Poschema.xml.

back to the top

Create a Purchase Order Document Definition

 * 1) Start the BizTalk Messaging Manager. On the File menu, click New, and then click Document Definition.
 * 2) For the Document Definition name:, type CommercePO.
 * 3) Click to check the Document specification: check box, and then browse to the Purchase Order schema Poschema.xml.
 * 4) Click OK.

back to the top

Create the Supplier Organization

 * 1) In the BizTalk Messaging Manager, click File, click New, and then click Organization.
 * 2) For the Organization Name:, type Supplier.
 * 3) Click OK.

back to the top

Create a Port to the Supplier Organization

 * 1) In the BizTalk Messaging Manager, on the File menu, click New, click Port, and then click To an Organization.
 * 2) For the Name:, type Port to Supplier, and then click Next.
 * 3) For the Organization Name, browse to Supplier, and then click OK.
 * 4) For the Primary Transport, click Browse, and then select HTTP for the Transport type:.
 * 5) For the Address:, type http://localhost/receive.asp, and then click OK.
 * 6) Click the Next button twice to advance through the wizard. Before you click Finish, make sure that the Create a channel for this messaging port: option is selected with a channel type of From an application.
 * 7) Click Finish. The New Channel Wizard will now start.

back to the top

Configure the Channel to the Supplier Organization

 * 1) In the New Channel Wizard, for Name:, select Channel to Supplier, and the click Next.
 * 2) Click Application, and then click New next to the Application Name.
 * 3) Click Add, for the Application Name:, type Retailer Site, and then click OK.
 * 4) Click OK again, make sure that Retailer Site is selected, and then click Next.
 * 5) For Document Definition, browse to CommercePO, click OK, and then click Next.
 * 6) For Document Definition, browse to CommercePO again, click OK, and then click Next.
 * 7) Click Next again, and then click Finish.

back to the top

Configure Commerce Server to Send Purchase Orders to BizTalk Server
 Start the Commerce Server Manager. Navigate to the App Default Config settings for the Retail Site by expanding Commerce Server Manager, expanding Commerce Sites, expanding Retail, expanding Site Resources, and then expanding App Default Config. Right-click App Default Config, and then click Properties to configure the site options as follows:

NOTE: Type the values exactly as they appear in the table.



back to the top

Import the Books Catalog into the Retail Site
If you do not already have the Books catalog available in your Retail Site, use the following steps to import the Books catalog into your Retail Site.
 * 1) Open the Commerce Server Retail Business Desk from the Start menu or click Start, click Run, and then type:


 * 1) To import a catalog, use the Import Catalog key combination ALT+I, and then press the ENTER key.
 * 2) Make sure that the Import XML option is selected, and then press the ENTER key.
 * 3) In the Import XML Catalog dialog box, type \Program Files\Microsoft Commerce Server\SDK\Samples\Sitelets\Auction\booksfull.xml for the file name, and then click OK.
 * 4) After the catalog import is successful, you should have the Books catalog available in your Retail Site.

back to the top

Associate the Books Catalog with the BizTalk Supplier Organization
 Restart IIS on your computer running Commerce Server by typing IISRESET at a command prompt, and then pressing the ENTER key on your keyboard. Start the Commerce Server Retail Business Desk from the Start menu or click Start, click Run and then type:

Expand the Business Desk Catalog module, and then click the Catalog Editor.</li> Click the Books catalog, and click the Open Catalog icon to open the Books catalog.</li> Click the ellipsis (...) next to the Vendor ID in the Catalog Properties section.</li> Select the Supplier vendor, and then click OK.

NOTE: The Supplier vendor is available in this list because it matches the list of vendors that are returned by running the btsint_organizations_selectvalidvendors stored procedure in the BizTalk InterchangeBTM database. This stored procedure takes the following input parameters, which are defined in the Retail Site's App Default Config.

The btsint_organizations_selectvalidvendors stored procedure in the BizTalk InterchangeBTM database runs whenever you click the ellipsis next to the Vendor ID in the Catalog Properties section of the Books catalog.</li> Click the Save icon or use the ALT+S key combination to save your changes, and then use the ALT+B key combination to go back to the Business Desk.</li> Publish the Books catalog with the ALT+P key combination or by clicking the Update Catalogs icon.</li></ol>

back to the top

Create the Receive.asp page in the Root Directory of the Default Web Site
Copy the following code into Notepad, and then save it in the default Web server root directory (Inetpub\Wwwroot by default) as Receive.asp: <% 'This page takes the BizTalk document from the 'ASP Request object and writes it to disk.

'Declare variables dim oDisk, oFile dim sDocument sDocument = ParseRequestForm set oDisk = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;) set oFile = oDisk.CreateTextFile(&quot;c:\purchaseorder.xml&quot;) oFile.WriteLine(sDocument) oFile.Close Response.End 'This function reads in the BizTalk file from the 'ASP Request object and translates it 'from binary to ASCII.

Function ParseRequestForm Dim PostedDocument Dim ContentType Dim CharSet Dim EntityBody Dim Stream Dim StartPos Dim EndPos

ContentType = Request.ServerVariables(&quot;CONTENT_TYPE&quot;)

'Determine request entity body character set (default is us-ascii)

CharSet = &quot;us-ascii&quot; StartPos = InStr(1, ContentType, &quot;CharSet=&quot;&quot;&quot;, 1) If (StartPos > 0) then StartPos = StartPos + Len(&quot;CharSet=&quot;&quot;&quot;) EndPos = InStr(StartPos, ContentType, &quot;&quot;&quot;&quot;,1) CharSet = Mid (ContentType, StartPos, EndPos - StartPos) End if

'Check for multipart MIME

PostedDocument = &quot;&quot; if (ContentType = &quot;&quot; or Request.TotalBytes = 0) then

'Content-Type and Entity body is required

Response.Status = &quot;406 Not Acceptable&quot; Response.Write &quot;Content-type or Entity body is missing&quot; & VbCrlf Response.Write &quot;Message headers follow below:&quot; & VbCrlf Response.Write Request.ServerVariables(&quot;ALL_RAW&quot;) & VbCrlf Response.End else if (InStr(1,ContentType,&quot;multipart/&quot;)>0) then 'MIME multipart message, Build the MIME header PostedDocument = &quot;MIME-Version: 1.0&quot; & vbCrLf & &quot;Content-Type: &quot; & ContentType & vbCrLf & vbCrLf PostedDocument = PostedDocument & &quot;This is a multi-part message in MIME format.&quot; & vbCrLf End if  'Get the post entity body

EntityBody = Request.BinaryRead (Request.TotalBytes) 'Convert to UNICODE Set Stream = Server.CreateObject(&quot;AdoDB.Stream&quot;) Stream.Type = 1          'adTypeBinary stream.Open Stream.Write EntityBody Stream.Position = 0 Stream.Type = 2           'adTypeText Stream.Charset = CharSet PostedDocument = PostedDocument & Stream.ReadText Stream.Close Set Stream = Nothing End if ParseRequestForm = PostedDocument End Function %>

back to the top

Test to Ensure that Purchases Completed on the Retail Site Generate Purchase Orders That Are Correctly Processed by BizTalk Server
Browse to the Retail Site, http://localhost/retail and complete a purchase.

NOTE: You will need to configure the Retail Site with a default shipping method. For more information on setting a default shipping method for a Commerce Store, see the Commerce Server 2000 online documentation.

If you successfully complete a purchase and if Commerce Server successfully submits a purchase order to BizTalk Server, the Purchaseorder.xml file will be created in the C:\ drive of the computer running BizTalk Server.

When you complete a purchase on the Retail Site, the following actions occur:  If BizTalk PO integration is enabled for the Commerce Site (App Default Config, BizTalk Options = 1) and if a customer purchases a product with an associated Vendor ID (as defined in the Commerce Server 2000 Catalog Editor), the Payment.asp file generates a purchase order and submits it to BizTalk Server with a call to Interchange.Submit using parameters in the following table.

</li> BizTalk Server routes the document to the appropriate channel based on the parameters in the submit call made in the Payment.asp file.</li> The channel performs document validation or mapping against the specified schema and passes the document to the associated port.</li> The port sends the file to the configured transport protocol of the file, HTTP, AIC, and so on. (HTTP is used in this example).</li> The Receive.asp file processes the incoming document and writes the purchase order to C:\Purchaseorder.xml.</li></ol>

back to the top

Keywords: kbhowtomaster kbdownload KB307599

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.