Did you know? – You can read / write to BAM database directly from outside BizTalk.

You know that BAM is used to gather statistics from your BizTalk application. What you probably don’t know is that:

%u00b7 You can collect BAM data from your non-BizTalk applications such as external .NET components that BizTalk calls into.

%u00b7 Tracking profile editor (TPE) is not the only way to collect data you can use a set of APIs available in the Microsoft.BizTalk.Bam.EventObservation namespace to read and write directly into the BAMPrimaryImport database.

Check out some of the links here:

%u00b7 http://www.topxml.com/rbnews/BizTalk-BAM-activity/re-29195_Business-Activity-Monitoring–GenerateTypedBAMAPI-Tool.aspx

%u00b7 http://www.developer.com/net/net/article.php/11087_3587296_2

%u00b7 http://blogs.msdn.com/keithlim/archive/2006/02/02/522649.aspx

%u00b7 http://blogs.msdn.com/keithlim/archive/2006/03/08/545851.aspx

Open Source BizTalk Projects on CodePlex

I am sure most of you (not talking about the BizTalk gurus out there J) have worked with some of the open source utilities available for BizTalk such as the BizTalk Adapter Wizard or the BizTalk Server Pipeline Component Wizard or BizUnit. However what some of you may not know is the wealth of other open source utilities for BizTalk available on CodePlex.

Here are some of the interesting ones and their descriptions as found on CodePlex :

SDC Tasks Library – . The SDC Tasks are a collection of MSBuild tasks designed to make your life easier. You can use these tasks in your own MSBuild projects. You can use them stand alone and, if all else fails, you can use them as sample code.

BizUnit – Framework for Automated Testing of Distributed Systems – BizUnit enables automated tests to be rapidly developed. BizUnit is a flexible and extensible declarative test framework targeted that rapidly enables the automated testing of distributed systems, for example it is widely used to test BizTalk solutions. BizUnit is fully extensible. Its approach is to enable test cases to be constructed from generic reusable test steps, test cases are defined in XML which allows them to be auto-generated and also enables the ’fixing up’ of Url’s for different environments, e.g. test, staging and production environments. Defining test cases in XML enables test cases to be auto-generated.

BizTalk Server Pattern Wizard – The BizTalk Pattern Wizard is an extensible tool to help you capture, share, and reuse your orchestration best practices. By using the BizTalk Pattern Wizard, you can capture a best practice, turn it into a generalized and configurable pattern, and share that pattern with the rest of your team or the entire BizTalk community. The wizard comes with over a dozen patterns ready for implementation in your next project.

WCF Adapter for BizTalk Server 2006

BizTalk Adapter Wizard for BizTalk Server 2006 – The BizTalk Adapter Wizard for BizTalk Server 2006 is a Visual Studio 2005 project wizard which creates all of the framework code for your custom BizTalk adapter. The adapter wizard is accessible from the Visual Studio menu: File – New – Project – BizTalk projects.

BizTalk Server 2006 Documenter – Creates compiled help files for a given BTS 2006 installation. This tool can be run on an ad-hoc basis using the UI or from the command line as a post build/deploy task to create a compiled help file describing a BTS 2006 installation. It will compile: BTS Host configuration, Send/Receive port configuration, Orchestration diagrams, Schema and Map content, Pipeline process flow, Adapter configuration, Rule engine vocabularies and policies, More and publish them as compiled help files. Optionally you can embed custom HTML content and custom descriptions for all BTS artifacts to produce a more customized look and feel to the CHM output

BizTalk Server 2006 Orchestration Profiler – Creates CHM report files illustrating the level of coverage for specified BizTalk orchestrations. This tool can be run to gain a consolidated view of orchestration tracking data for a specified period of time to help developers get an idea of how their orchestrations are being processed and how much coverage they are getting in their testing. In addition to simple coverage information the data presented helps to identify latency and code path exceptions by highlighting long running and error prone orchestration shapes.

PowerShell BizTalk Provider – A full PowerShell provider for exposing BizTalk Server as a filesystem. Administer your BizTalk installation. List all applications / orchestrations / Schemas. Stop an application, enlist an orchestration … Use the full power of the shell to script away the pain of GUI based mass-management.

MapCop – A program for testing BizTalk map files (.BTM) for a set of best practices.

BizTalk Instance Controller – Limit the number of instances of any BizTalk Service.

Have Fun!

Links to materials on GoF Design Patterns

As I am into BizTalk consulting / development / training for quite sometime now, I feel that I am missing out on hardcore c# programming and the enchantment of object oriented concepts lately.

For instance, the other day I was trying to recollect the implementation details of the Decorator design pattern, and searched for it on the Internet and in the process,got glued at the wealth of information available on design patterns.

So I thought it would be helpful to have a quick reference list of the materials available so that i don’t waste time searching for them again.

Here goes:

Abstract Factory
http://www.dofactory.com/Patterns/PatternAbstract.aspx
http://en.wikipedia.org/wiki/Abstract_factory_pattern
http://www.exciton.cs.rice.edu/JAvaResources/DesignPatterns/FactoryPattern.htm

Factory Method
http://www.dofactory.com/Patterns/PatternFactory.aspx
http://en.wikipedia.org/wiki/Factory_method_pattern
http://gsraj.tripod.com/design/creational/factory/factory.html

Facade
http://www.dofactory.com/Patterns/PatternFacade.aspx
http://en.wikipedia.org/wiki/Facade_pattern
http://aspalliance.com/970_Facade_Design_Pattern

Iterator
http://www.dofactory.com/Patterns/PatternIterator.aspx
http://home.earthlink.net/~huston2/dp/iterator.html
http://www.c-sharpcorner.com/UploadFile/acusis/IteratorPattern07072006023056AM/IteratorPattern.aspx

Observer
http://www.dofactory.com/Patterns/PatternObserver.aspx
http://en.wikipedia.org/wiki/Observer_pattern
http://www.exciton.cs.rice.edu/JAvaResources/DesignPatterns/ObserverObservable.htm
http://sern.ucalgary.ca/courses/SENG/609.04/W98/lamsh/observerLib.html

Singleton
http://www.dofactory.com/Patterns/PatternSingleton.aspx
http://en.wikipedia.org/wiki/Singleton_pattern
http://www.exciton.cs.rice.edu/JAvaResources/DesignPatterns/singleton.htm
http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html

Adapter
http://www.dofactory.com/Patterns/PatternAdapter.aspx
http://en.wikipedia.org/wiki/Adapter_pattern
http://www.exciton.cs.rice.edu/JAvaResources/DesignPatterns/adapter.htm
http://vico.org/pages/PatronsDisseny/Pattern%20Adapter%20Object/index.html


More to follow soon…

HL7 Dynamic Data Validation

In the documentation for HL7 there is an interesting chapter called Using Dynamic Data Validation and it is located here. To explain how this is to be done you first have to go into the HL7 configuration explorer and disable the data validation.

This will allow data to arrive without being checked against its Enumeration:

This however will not disable the structure validation that is the pain point of most HL7 implementations.

Once data is structurally validated, then the message arrives into the orchestration you then start to use the Business Rules engine to validate the data

This is the starting point of how you enable Dynamic Data Validation using the HL7 accelerator

More on Mind Mapping

More on Mind Mapping

A site called Innovation Tools (which I recommend) published in September 2006 the results of a survey on mind mapping software (in PDF). MindManager is the clear leader, with ~70% usage, with the open source FreeMind at ~10% (which I tried before prefering MindManager).

This survey is especially interesting when you see the diversity of topics people use this kind of apps for: to-do lists, preparing presentations, taking notes, solve problems, plan projects, decision making, etc. According to the survey, the single most important benefit of using mind mappers is “Clarity of Thinking“. This is very true, and you can get results very quickly. A simple map can take me ~15mins to create, and usually the result can be used directly in your work (for example, for the titles of a PowerPoint presentations, or the chapters of a word document, or even a database structure or class diagram).

What is this new BizTalk 2006 R2 Adapter Framework

Thought I’d collect a few resources to help you guys along the way with some great
articles from Sonu(PM for the .NET
Adapter Framework) :
Well worth a read.

Here is additional information on creating custom adapters using BizTalk Adapter
Framework-
Developing Adapters Using the Adapter Framework
http://msdn2.microsoft.com/en-us/library/ms944509.aspx

Developing Custom Adapters

http://msdn2.microsoft.com/en-us/library/aa559841.aspx

Writing Effective BizTalk Server Adapters
http://msdn2.microsoft.com/en-us/library/ms942193.aspx

MindJet’s MindManager 7

MindJet’s MindManager 7

I’ve been an (irregular) fan of Mind Mapping for several years, previously using simple flip-charts. and later Visio’s Brainstorming diagram or a simple whiteboard. Recently, one of my associates purchased a license of the brand new MindJet MindManager 7 Pro, and I’ve gone back to using this technique with renewed energy.

I frequently toy with my friends about the best tool of all, CPL 1.0 (in English, this would be translatable as BPP 1.0 — Brain, Paper and Pencil :-)), but this tool is a very close second :-). Basically, MindManager allows you to create diagrams with everything that pops into your mind, organizing concepts or actions or ideas in a hierarchical approach across a central concept. You can do stuff such as create relationships, export to formats such as PowerPoint or Visio or MS Project (including resource usage and task-related information), synchronize with Outlook’s Task List (at last, hierarchically organized tasks!!! — great for GTD fans like myself) or Appointments, etc. Version 7 comes with a Ribbon interface just like Office 2007, which also makes it easy to use and great looking.

I probably sound like a salesman, which I am not, but this is because I ready like this tool. I am the kind of person that pops out a notebook or rushes to a whiteboard to help structure ideas and think/draw things out, and I’ve realized in the few days that I’ve been using this, that it is astonishingly easy doing it in MindManager.

MindJet has a 21-day trial I recommend people try out. The price is not cheap for local standards (299.00 for the Pro version, 79 for the Lite one), but I’d very easily spend the money on this.

To give you some ideas of diagrams we’ve done in the past days: to structure competencies around hiring of non-technical resources, the company’s strengths and weaknesses, at least 2 tactical approaches to projects including action points and things to take into consideration, ideas about an architecture to a project, and my own Outlook task list. 

Great Software: 5 Jota’s out of 5 🙂

 

Disclosure: as an MVP, I have received a free license for MindManager 7 as a 3rd party offer from MindJet.

Sending HTML emails with embedded images in BizTalk

Ever wanted to send emails from BizTalk (using the SMTP adapter) which have images embedded in them? I did recently.

Sending HTML emails (or text emails) in BizTalk without embedded images has been done
to death – all you need is the RawString
message type.

But how do you use the SMTP adapter to send emails with embedded images?
I didn’t want to cheat and write a helper class.

I first looked at using the MIME/SMIME encoder pipeline component.
By default the MIME encoder uses a mime Content-Type of multipart/mixed.

So if you have a multipart message with an HTML body part and a single image as a
second part, this is what the MIME encoder generates:

MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary=”–=_NextPart_001_000D_01C79667.1A2EEFB0″
Return-Path: [email protected]

This is a multi-part message in MIME format.

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: text/html; charset=UTF-8;
    charset=”utf-8″
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/

<html></html>

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://localhost/images/logo.gif
Content-ID: <http://localhost/images/logo.gif>

However, multipart/mixed is not how you embed content – you need to use multipart/related,
to indicate that all the parts in the message are related.

(Note: in order to view the output of the SMTP adapter I used the IIS SMTP
service, and configured the SMTP adapter to use an SMTP server of localhost,
and a To Address which matched my local domain. This will generate EML files
in \Inetpub\mailroot\Drop which you can open using Outlook Express (or notepad)).

There’s a little known MIME context property you can set called IsMultipartRelated.
If you use this, and have all your images as parts to the message, with your HTML
part as the body part, then the SMTP adapter will send a message which can be viewed
in a few email clients e.g. Outlook.
If you use this property, this is what the MIME encoder will output:

MIME-Version: 1.0
Content-Type: multipart/related;
    type=”text/html”;
    boundary=”–=_NextPart_001_000D_01C79667.1A2EEFB0″
Return-Path: [email protected]

This is a multi-part message in MIME format.

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: text/html; charset=UTF-8;
    charset=”utf-8″
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/

<html></html>

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://localhost/images/logo.gif
Content-ID: <http://localhost/images/logo.gif>

However this doesn’t work for any web based browsers e.g. Hotmail, Yahoo, SquirrelMail,
or LotusNotes.

Reading the RFC for Multipart
HTML messages
showed me what I was missing: The Content-Type for the complete
message needs to be multipart/related, but the first (body) part needs to consist
of two parts, and have a Content-Type of multipart/alternative. – that is,
the first part is actually another multi-part message!
The reason for this is the body part contains a Text part, and an HTML part – so that
browsers which don’t understand HTML can still display the message.
It appears that a lot of email browsers won’t display messages unless they are in
this format and, in fact, this is what the RFC recommends.

Problem is, the MIME encoder does not support this (as far as I can make out – there’s
a promising property called PartContentTypeSecondaryHeader but I couldn’t get
it to work for me, plus IBaseMessagePart doesn’t act as a container for other
parts, so it’s unclear how you’d represent it in a message anyway).

So I wrote a pipeline component which takes an HTML stream as input, parses it and
downloads all the resources, and then does the correct MIME encoding.
This is the output from my component:

MIME-Version: 1.0
Content-Type: multipart/related;
    type=”multipart/alternative”;
    boundary=”–=_NextPart_001_000D_01C79667.1A2EEFB0″
Return-Path: [email protected]

This is a multi-part message in MIME format.

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: multipart/alternative;
    boundary=”–=_NextPart_001_000E_01C79667.1A2EEFB0″

—-=_NextPart_001_000E_01C79667.1A2EEFB0
Content-Type: text/plain;
    charset=”iso-8859-1″
Content-Transfer-Encoding: 8bit

Plain text version of the email

—-=_NextPart_001_000E_01C79667.1A2EEFB0
Content-Type: text/html;
    charset=”utf-8″
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/

<html></html>

—-=_NextPart_001_000E_01C79667.1A2EEFB0–

—-=_NextPart_001_000D_01C79667.1A2EEFB0
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://localhost/images/logo.gif
Content-ID: <http://localhost/images/logo.gif>

The next trick was trying to get the SMTP adapter to accept the output from my component:
In BizTalk, there are two ways of MIME encoding content: simple encoding is performed
by the SMTP adapter (e.g. if you don’t use the MIME encoder); more advanced encoding
is performed by the MIME encoder.

So obviously the MIME encoder sets a property which indicates that the message is
already MIME encoded so the SMTP adapter doesn’t need to bother.
If you look at the list of context properties which the MIME encoder supports, you see
there’s one called IsMIMEEncoded.
Seems pretty obvious.


Except that the property doesn’t work.

I had to add a Debug pipeline component which would dump all the context properties
attached to a message after the MIME encoder had finished with it to find the answer.
Turns out there’s another context property called MimeEncoded (note the lack
of capitalisation), which is in the System namespace (not the MIME namespace) and
can only be set from code.
And this is the one that the SMTP adapter looks for. You can set it like this:
    inmsg.Context.Write(“MimeEncoded”,
   “http://schemas.microsoft.com/BizTalk/2003/system-properties”, true);

And now it works: I get email with embedded resources which can viewed correctly in
all mail browsers (except Lotus Notes, which occasionally doesn’t show images – but
that’s Notes for you!)

As an aside, whenever I write a pipeline component, I always try and have it work
in a streaming fashion (check out Christof
Claessens’ great article about this).
However when I reflected over the source of the MIME encoder, I noticed that it doesn’t
chain the streams – during the IComponent.Execute()call,
the encoder reads the streams of all parts and returns a new message with a single
part. So it’s not implemented in a streaming fashion (i.e. you can’t chain together
all the streams from all components).

What I haven’t covered in this post is how to use Content-ID and the cid: prefix
(in your html) to link the embedded resources to the parts in your mime message –
you can see examples of this in the RFC.