NOTE: Microsoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
Steps to Create an AIC in Microsoft Visual Basic to Parse an XML Document into SQL Server 2000
- Create a new empty database in SQL Server 2000, start the SQL Server Query Analyzer, switch context to your newly created database, and then run the following SQL Server commands on your SQL Server 2000 computer to create the necessary tables and stored procedures: (Note that you do not need to run the first three lines if this is the first time you are running it.)
drop procedure ReloadNews
drop table news
go
CREATE TABLE [News] (
[sCat] [char] (8) NOT NULL ,
[sCatName] [char](64) NOT NULL ,
[sHeadline] [char] (128) NOT NULL ,
[sURL] [varchar] (256) NOT NULL
)
GO
create clustered index NewsCat on News(sCat)
go
create procedure ReloadNews
@doc text
as
begin transaction
declare @iDoc int
exec sp_xml_preparedocument @idoc OUTPUT, @doc
delete from news
insert into News (sCat, sCatName, sHeadline, sURL)
SELECT *
FROM OPENXML (@idoc, '/list/headline',0) WITH
(
groupid varchar(8),
groupname varchar(64),
title varchar(128),
url varchar(256)
)
exec sp_xml_removedocument @iDoc
if (select count(*) from news) > 0
commit transaction
else
rollback transaction
GO
grant select on News to public
grant execute on ReloadNews to public
go
- Start Visual Basic 6.0, and then create a new ActiveX DLL project.
- Add the following references to the project:
- Microsoft BizTalk Server Application Interface Components 1.0 Type Library (Btscomplib.tlb)
- Microsoft ActiveX Data Objects 2.5 Library (Msado15.dll)
- Microsoft XML, v3.0 (Msxml3.dll)
- Paste the following code into the Code window for the class:
Implements IBTSAppIntegration
Public Function IBTSAppIntegration_ProcessMessage(ByVal bstrDocument As String) As String
LoadtoSQL bstrDocument
IBTSAppIntegration_ProcessMessage = True
End Function
Function LoadtoSQL(loadtotable)
Dim cn
Dim cmd
Dim xmlDOM
Const adCmdStoredProc = 4
Const adChar = 129
Const adParamInput = 1
Set xmlDOM = CreateObject("MSXML2.DOMDocument")
xmlDOM.async = False
xmlDOM.LoadXML loadtotable
Set cn = CreateObject("adodb.connection")
cn.Open "Provider=sqloledb; Data Source=(local);Initial Catalog=master;", "sa", ""
Set cmd = CreateObject("adodb.command")
cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "ReloadNews"
cmd.Parameters.Append cmd.CreateParameter("@doc", adChar, adParamInput, Len(xmlDOM.xml), xmlDOM.xml)
cmd.Execute
If Err.Number <> 0 Then
loadtotable = "error"
Else
loadtotable = Err.Number
End If
Set cmd = Nothing
Set cn = Nothing
Set xmlDOM = Nothing
End Function
NOTE: You must change the following line of code to match the data source and name of the table that you created in step two (Initial Catalog= ) and provide the appropriate values for the user name and password:
cn.Open "Provider=sqloledb; Data Source=(local);Initial Catalog=master;", "sa", "password"
- Rename the class to loadtotable, save the project as Loadtotable.vbp, and then compile and make Loadtotable.dll.
- Register the DLL on the BizTalk Server computer. (Type regsvr32 loadtotable.dll from a command prompt.)
- Start the Component Services Microsoft Management Console (MMC) interface. To do this, click Start, point to Programs, point to Administrative Tools, and then click Component Services.
- Click to expand the Component Services MMC snap-in, and continue expanding until you reach COM+ Applications.
- Right-click COM+ Applications, click New, click Application, and then click Next.
- Click Create an empty application.
- Enter a name for the application, and then click Next.
- Click the This user: radio button and type in the username and password for the account that you want this application to run under.
- Click Finish.
- Navigate through the list of COM+ applications and expand your newly created application.
- Right-click the Components folder for this application, click New, click Component, and then click Next.
- Click Install new component(s), browse to the DLL that you created in step 5, select the DLL, click Open, click Next, and then click Finish.
You now have a BizTalk Application Integration component to parse an XML stream into a SQL Server table. If you expand the Components folder, you can see the interfaces for your component, including the
IBTSAppIntegration interface that BizTalk Server needs to call the component.
To test this Application Integration Component, create a file receive function to grab the News.xml file that is extracted from the News.exe download, and then hand it off to a channel that is matched to a port that has a primary transport of Application Integration Component. Because the component exposes the
IBTSAppIntegration interface, you can browse to the component when you choose the component name for a transport type of Application Integration Component when you configure the destination port in the Messaging Manager.
The following file is available for download from the Microsoft Download Center:
The News.exe file contains the following files:
Collapse this tableExpand this table
File Name | Size |
---|
News.xml | 46.8 KB (47,938 bytes) |
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591�
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.