Microsoft KB Archive/316633

= HOW TO: Create a BizTalk AIC That Posts to an IIS Server and Processes the Response of the IIS Server =

Article ID: 316633

Article Last Modified on 6/4/2003

-

APPLIES TO


 * Microsoft BizTalk Server 2000 Standard Edition
 * Microsoft BizTalk Server 2002 Standard Edition

-



This article was previously published under Q316633



In This Task
 SUMMARY

Create a Visual Basic 6.0 Application Integration ComponentCreate the Receiving Web page on Trading Partner's IIS ServerCreate a Channel and Port and Test the AIC





SUMMARY
This article describes how to create a BizTalk Application Integration Component (AIC) that sends a document to a trading partner's Internet Information Services (IIS)-based server and writes the IIS server's response to a text file. This scenario may be useful for exchanging business documents with trading partners that do not use Microsoft BizTalk Server.

back to the top

Create a Visual Basic 6.0 Application Integration Component
 Start a new ActiveX dynamic-link library (DLL) project in Microsoft Visual Basic 6.0. Add the following references to the project:  Microsoft XML, 3.0 (\Winnt\System32\Msxml3.dll) Microsoft BizTalk Server Application Interface Components 1.0 Type Library (\Program Files\Microsoft BizTalk Server\Btscomplib.tlb) Microsoft Scripting Runtime (\Winnt\System32\Scrrun.dll)</li></ul> </li>  Paste the following code into the class for this project: '******************************************* 'XMLHTTPAIC.cls Option Explicit Implements IBTSAppIntegration Dim responseobj As String Dim msg As String Dim webserveraddress As String Dim objXMLHTTP As New MSXML2.ServerXMLHTTP Dim xmldoc As New DOMDocument Dim FileSystemObject As New Scripting.FileSystemObject Dim ts Dim responsetxt As String

Private Function IBTSAppIntegration_ProcessMessage(ByVal bstrDocument As String) As String On Error GoTo ExecuteError SendHTTP bstrDocument

IBTSAppIntegration_ProcessMessage = responseobj msg = &quot;&quot; webserveraddress = &quot;&quot; Set objXMLHTTP = Nothing Set xmldoc = Nothing Set ts = Nothing Set FileSystemObject = Nothing responseobj = &quot;&quot; responsetxt = &quot;&quot; Exit Function ExecuteError: On Error GoTo 0 Err.Raise Err.Number, Err.Source, &quot;The following Error was encountered: &quot; + Err.Description End Function

Private Function SendHTTP(strData As String) xmldoc.loadXML (strData) msg = CStr(xmldoc.xml) webserveraddress = &quot;http:// /response.asp&quot; objXMLHTTP.open &quot;POST&quot;, webserveraddress, False objXMLHTTP.send msg responseobj = objXMLHTTP.responsetext xmldoc.loadXML (responseobj) responsetxt = xmldoc.documentElement.childNodes(0).Text Set ts = FileSystemObject.CreateTextFile(&quot;c:\response\&quot; & responsetxt & &quot;.xml&quot;, True) ts.Write responseobj ts.Close End Function '*******************************************                   </li> Create a folder named response on drive C of the BizTalk server.</li> Modify the webserveraddress variable to point to the name of the trading partner's receiving Web page.</li> Change the name of the project to BTSAIC .</li> Change the name of the class to XMLHTTPSend .</li> Save the project as XMLHTTPAIC.vbp, and then save the class as XMLHTTPAIC.cls .</li> Create the XMLHTTPAIC.dll file.</li> Start the Component Services snap-in.</li> In the console tree, right-click COM+ Applications, click New, click Application, and then click Next.</li> Create an empty application with the name XMLHTTPAIC as a Server Application, and then click Next.</li> Under Account, click This user, and then type the user name and password of your BizTalk Service account or of an account that is a member of the BizTalk Server Administrators group.</li> Click Next, and then click Finish.</li> Expand the newly created XMLHTTPAIC package, right-click Components, point to New, and then click Component. Click Next.</li> Click Install new component(s), click Add, and then browse to the XMLHTTPAIC.dll file that you compiled.</li> Click Next, and then click Finish.

You have now created the necessary Application Integration Component to post your document from a Messaging Port to your trading partner.</li></ol>

back to the top

Create the Receiving Web Page on a Trading Partner's IIS Server
<ol> <li> Paste the following ASP script into Notepad, and then save it to the home directory of the trading partner's IIS server as response.asp : <%@ Language=VBScript %> <% 'response.asp Dim PostedDocument Dim EntityBody Dim Stream Dim FileSystemObject Dim ts Dim stResponse Dim rnum Dim responsedoc Dim filesaved

Set FileSystemObject = CreateObject(&quot;Scripting.FileSystemObject&quot;) EntityBody = Request.BinaryRead (Request.TotalBytes ) Set Stream = CreateObject(&quot;AdoDB.Stream&quot;) Stream.Type = 1 Stream.Open Stream.Write EntityBody Stream.Position = 0 Stream.Type = 2 Stream.Charset = &quot;us-ascii&quot; PostedDocument = PostedDocument & Stream.ReadText Stream.Close

filesaved = 0 do until filesaved = 1 'generate random number for response document filename and contents Randomize rnum = int((9000 * Rnd) + 1000) stResponse = DatePart(&quot;m&quot;, Now) & DatePart(&quot;d&quot;, Now) & DatePart(&quot;h&quot;, Now)& DatePart(&quot;n&quot;, Now)& rnum

'write document received to incoming directory On Error Resume Next Set ts = FileSystemObject.CreateTextFile(&quot;c:\incoming\&quot; & stResponse & &quot;.xml&quot;,False) if err.number = 0 then filesaved = 1 err.clear loop

On Error GoTo 0

ts.write PostedDocument ts.close 'send response document back to initiator Set responsedoc = CreateObject(&quot;MSXML2.DomDocument&quot;) responsedoc.loadXML (&quot;<Response> </Response>&quot;) responsedoc.documentElement.childNodes(0).text = stResponse Response.Write responsedoc.xml Response.Status = &quot;202 Accepted&quot; Response.End

PostedDocument = &quot;&quot; Set EntityBody = Nothing Set Stream = Nothing Set FileSystemObject = Nothing Set ts = Nothing stResponse = &quot;&quot; rnum = 0 Set responsedoc = nothing filesaved = 0 %>                   </li> <li>Create a folder named incoming on drive C of the trading partner's IIS server.</li></ol>

back to the top

Create a Channel and Port and Test the AIC
<ol> <li>Create a BizTalk Messaging Port with a transport of Application Integration Component. When you are prompted for the Primary Transport, point to the component name that was created when you created the XMLHTTPAIC COM+ application, which should be BTSAIC XMLHTTPSend. Create a Channel bound to this Port.</li> <li>Use the Direct Integration SDK Sample that is located the following folder to send a document to the Channel that you created:

\Program Files\Microsoft BizTalk Server\SDK\Messaging Samples\DirectIntegration\EXE\DirectIntegration.exe

</li></ol>

Result:

The Response.asp page on the trading partner's IIS server should write the business document to the C:\Incoming folder of the IIS server. The XMLHTTPAIC AIC should write the IIS server's response document into C:\Response folder on the BizTalk server.

back to the top

Keywords: kbhowto KB316633

-

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

© Microsoft Corporation. All rights reserved.