BizTalk Server 2004 : B2B, EAI and .NET

Tuesday, August 31, 2004

Sending Messages as FORM Variables with the HTTP Adapter

Here's a quickie. If you want to send a message, as a FORM Variable in a HTTP request, this is what you do:

1) Set the Content Type property of the HTTP send port, to application/x-www-form-urlencoded.

2) Create a custom pipeline and plug-in a Custom Pipeline Component, that pre-pends Variable-Name= in front of the message, and url encode it. e.g: ClaimPacket=

3) Use this pipeline with your HTTP send port, and you are done!

Post a comment for a sample.

Update : Screen shot of the Content Type property:


View complete post...

Thursday, August 26, 2004

Event Log Message Interception with WMI

Out of the box pipeline components have decent error logging, but often don't give us the flexibility to do our own thing. In addition to a suspended queue listener (see Martinjn's blog), an Event Log Watcher windows service might be a good failover mechanism. Below is some skeleton code for going about it.

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Management;
using System.IO;

namespace MyEventLogWatcher
{
public class BizTalkEventLogWatcher : System.ServiceProcess.ServiceBase
{
private System.Management.ManagementEventWatcher eventLogWatcher;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public BizTalkEventLogWatcher()
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
}

static void Main()
{
System.ServiceProcess.ServiceBase ServiceToRun;

ServiceToRun = new BizTalkEventLogWatcher();

System.ServiceProcess.ServiceBase.Run(ServiceToRun);
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.eventLogWatcher = new System.Management.ManagementEventWatcher();
//
// eventLogWatcher
//

this.eventLogWatcher.Query = new System.Management.EventQuery("SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA \"Win32_NTLogEvent\"" +
" AND TargetInstance.Logfile = \"Application\"");

//
// BizTalkEventLogWatcher
//
this.ServiceName = "BizTalkEventLogWatcher";

}
#endregion

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}

}
base.Dispose( disposing );
}

///
/// Set things in motion so your service can do its work.
///

protected override void OnStart(string[] args)
{
eventLogWatcher.Scope = new System.Management.ManagementScope("\\\\"+Environment.MachineName+"\\root\\CIMV2");
eventLogWatcher.EventArrived += new System.Management.EventArrivedEventHandler(eventLogWatcher_EventArrived);
eventLogWatcher.Start();
}

///
/// Stop this service.
///

protected override void OnStop()
{
eventLogWatcher.Stop();
}
protected void eventLogWatcher_EventArrived(object sender, EventArrivedEventArgs e)
{
string strEventSourcesToIntercept = "";
try
{
PropertyData propData = e.NewEvent.Properties["TargetInstance"];
StringBuilder strUserFriendlyMsg = new StringBuilder();
if(propData != null)
{
ManagementBaseObject mgmtObj = propData.Value as ManagementBaseObject;
if((mgmtObj.Properties["Message"].Value != null)&&
(mgmtObj.Properties["Source"].Value.ToString().Equals("strEventSourcesToIntercept")))
{

}
}
}
catch(Exception Ex)
{
//error handling
}
}

}
}


View complete post...

Wednesday, August 25, 2004

Uniform Sequential Convoys in BTS 2004 using Correlation

This orchestration is a small primer if you want to implement a "Sequential Convoy " with BizTalk 2004. You would want to do this if:

a) You have to force messages coming in at a particular port to correlate together and get processed by the same orchestration instance.
(Correlation with multiple ports is a topic of a subsequent post)
b) You want your output messages to be delivered in the same order that the orchestration got them.
c) Some pipeline components you use, take one message but give out multiple messages, but you want to process these multiple messages together. For eg: the HIPAA and HL7 disassembler components.

...and probably some more scenarios that I can't think of right now.

The attached orchestration correlates messages w.r.t ReceivedFileName (think about the HIPAA 835 scenario mentioned above). You can use whatever correlation parameters you desire.

TIP: Whatever properties you choose to correlate the incoming messages with, make sure that these properties are promoted when the message(s) reach the MessageBox. Since the RecievedFileName property is not promoted by default, I have also attached a pipeline component which promotes it before it reached the MessageBox.

You can get the source files here .

Any questions, lemme know. Cheers!



View complete post...