HOW TO: Submit Orders to Microsoft BizTalk Server from Commerce Server 2000 (307599)



The information in this article applies to:

  • Microsoft BizTalk Server 2000
  • Microsoft Commerce Server 2000

This article was previously published under Q307599

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
  2. 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.
  3. Click Create a new site, and then click Next.
  4. When you are prompted, set the Custom unpack option to the site name Retail.
  5. In the Unpack Method dialog box, click Create a new site, and then click Next.
  6. Enter the site name Retail, and then click Next.
  7. In the Select Resources dialog box, click Next.
  8. In the Global Resource Pointers dialog box, click Next.
  9. In the Database Connection Strings dialog box, click Next. If you are prompted, enter the appropriate Microsoft SQL Server user name and password.
  10. In the Select Applications dialog box, make sure that the Retail and RetailbizDesk check boxes are selected (checked), and then click Next.
  11. In the Select IIS Web Sites and Virtual Directories dialog box, keep the default settings, and then click Next.
  12. When the Data Warehouse dialog box appears, change the name of the Data Warehouse to Data Warehouse Retail, and then click OK.
  13. In the Profiling dialog box, keep the default settings, click Next, and then click OK.
  14. When the Unpacking is complete! dialog box appears, click Finish.
  15. 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

  1. Start the Commerce Server Manager.
  2. 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.
  3. 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.

    OptionValue
    BizTalk Options1
    BizTalk PO Doc TypeCommercePO
    BizTalk Source Org QualifierOrganizationName
    BizTalk Source Org Qualifier ValueHome Organization
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:

       <drive letter>:\Program Files\Microsoft Commerce Server\Retail LOCALHOST 80.hta
  2. To import a catalog, use the Import Catalog key combination ALT+I, and then press the ENTER key.
  3. Make sure that the Import XML option is selected, and then press the ENTER key.
  4. 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.
  5. 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

  1. Restart IIS on your computer running Commerce Server by typing IISRESET at a command prompt, and then pressing the ENTER key on your keyboard.
  2. Start the Commerce Server Retail Business Desk from the Start menu or click Start, click Run and then type:

        <drive letter>:\Program Files\Microsoft Commerce Server\Retail LOCALHOST 80.hta
  3. Expand the Business Desk Catalog module, and then click the Catalog Editor.
  4. Click the Books catalog, and click the Open Catalog icon to open the Books catalog.
  5. Click the ellipsis (...) next to the Vendor ID in the Catalog Properties section.
  6. 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.

    ParameterValue
    BizTalk Source Org QualifierOrganizationName
    BizTalk Source Org Qualifier ValueHome Organization
    BizTalk PO Doc TypeCommercePO

    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.
  7. 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.
  8. Publish the Books catalog with the ALT+P key combination or by clicking the Update Catalogs icon.
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("Scripting.FileSystemObject")
set oFile = oDisk.CreateTextFile("c:\purchaseorder.xml")
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("CONTENT_TYPE")

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

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

'Check for multipart MIME

PostedDocument = ""
if (ContentType = "" or Request.TotalBytes = 0) then

'Content-Type and Entity body is required

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

   EntityBody = Request.BinaryRead (Request.TotalBytes)
		   
   'Convert to UNICODE
  
   Set Stream = Server.CreateObject("AdoDB.Stream")
   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:
  1. 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.

    ParameterValue
    BIZTALK_OPENNESS_TYPE BIZTALK_OPENNESS_TYPE_NOTOPEN
    Source QualifierFrom the value entered into the Commerce Site App Default Config
    Source Qualifier ValueFrom the value entered into the Commerce Site App Default Config
    Destination QualifierIndirectly determined from the vendor associated with that product in the Commerce Server Catalog that contains the product
    Destination Qualifier ValueFrom the vendor associated with that product in the Commerce Server Catalog that contains the product
  2. BizTalk Server routes the document to the appropriate channel based on the parameters in the submit call made in the Payment.asp file.
  3. The channel performs document validation or mapping against the specified schema and passes the document to the associated port.
  4. The port sends the file to the configured transport protocol of the file, HTTP, AIC, and so on. (HTTP is used in this example).
  5. The Receive.asp file processes the incoming document and writes the purchase order to C:\Purchaseorder.xml.
back to the top





Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbHOWTOmaster KB307599 kbAudDeveloper