Tuesday, March 25, 2008

Microsoft BizTalk Adapter Pack

The BizTalk Adapter Pack (BAP) became available a couple of weeks ago. The BAP provides a robust and comprehensive out-of-the-box connectivity infrastructure to three major line-of-business (LOB) systems - SAP, Siebel, and Oracle Databases. The technology is based on the WCF LOB Adapter SDK and inherently relies on the core WCF concepts, principles, and classes implemented in the .NET Framework 3.5.

What’s in the BizTalk Adapter Pack?

  • SAP Adapter
  • ADO.NET Data Provider for SAP
  • Siebel Adapter
  • ADO.NET Data Provider for Siebel
  • Oracle Database Adapter

Read more on the MSDN-blog.

Thursday, February 28, 2008

Configuration File Corrupt

Recently, when i tried to open my BizTalk Adminconsole it got the following errormessage:

root element is missing (c:\Documents and Settings\UserName\Local Settings\Application Data\Microsoft Corporation\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Administration.Snapin.dll.config)".

To solve this error, just delete the Microsoft.BizTalk.Administration.Snapin.dll.config file.
Next time the Adminconsole will recreate this configfile :)

Friday, February 22, 2008

Binding an orchestration to multiple receive ports

In the BizTalk Server 2006 Admin Console, it's only possible to bind 1 physical Receive Port to 1 logical (Orchestration-)Receive Port.
To bind multiple receive ports to an orchestration, you could follow these steps:
  1. Create multiple Receive Ports with their Receive Locations in the Admin Console,
    use friendly portnames, you need them to create an expression later on.
  2. In your Orchestration select your activating Receive Shape and configure the "Filter Expression" by clicking the ellipsis. In the Filter Expression add as many "BTS.ReceivePortName"-properties as Receive Ports you have created.
    Set the values of the properties to the portnames of the Receive Ports and group each row by "OR".
    The Filter Expression should resemble something like this:
    (BTS.ReceivePortName == "ReceiveMsgPort1") (BTS.ReceivePortName == "ReceiveMsgPort2")
  3. Create an Orchestration Receive Port and specify its binding to "Direct Binding", also make sure "Routing between ports will be defined by filter expressions on incoming messages in the Messagebox database" is selected.
  4. Make sure that the "Partner Orchestration Port"-property of your Orchestration Receive Port is set to "Message Box".
  5. Now deploy your Application, all the messages which originate from the filtered ports will be processed by the Orchestration.

Tuesday, February 19, 2008

BizTalk Documenter, BizTalk Orchestration Profiler & BizUnit

Three tools every BizTalk-developer should be aware of, are BizTalk Documenter, BizTalk Orchestration Profiler and BizUnit. The documentation below is copied from the homepages of these tools.

BizTalk 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, … 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.
Get it: http://www.codeplex.com/BizTalkDocumenter

BizTalk 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 which is key to effective performance testing.
Get it: http://www.codeplex.com/BiztalkOrcProfiler

BizUnit
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.
Get it: http://www.codeplex.com/bizunit

Tuesday, February 12, 2008

Master Secret Server not available

When configuring BizTalk, you might bump into this error: "Cannot perform encryption or decryption because the secret is not available from the master secret server".

A simple way to solve this problem:
  • Open a command prompt
  • Navigate to C:\Program Files\Common Files\Enterprise Single Sign-On\
  • Type in this command:
    ssoconfig -restoresecret SSO3F38.bak (or another file that looks like this one, it's the SSO back-up file)
  • Enter the password
  • Create a new back-up file with this command:
    ssoconfig -backupsecret latestbackup.dat

Tuesday, February 5, 2008

Sending a mail with an attachment & body text

To send an email-message that has attachment and also has a bodytext you need to work arround a few issues.
Normally you would create a send pipeline with a MIME encoder and set the "send body part as attachment" to True. This however, will cause your email bodytext to state "This message has attachments.", no matter what you've set to be the SMTP.EmailBodyText-value.
To work arround this issue, you have to take the following steps:

  1. Create a custom send pipeline and add a MIME encoder, leave this as is.
  2. In your orchestration view, create a new MultiPartMessageType with 2 Message Parts, a BodyPart and an AttachmentPart. Set the "Message Body Part" property to respectively True and False. Also, set the "Type" property of the BodyPart to the schema of the message you want to add as an attachment.
    The "Type" property of the AttachmentPart should be a .NET Class called "RawString".
    This is a custom class that contains the following code:

using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using Microsoft.XLANGs.BaseTypes;
namespace Microsoft.Samples.BizTalk.XlangCustomFormatters
{
public abstract class BaseFormatter : IFormatter
{
public virtual SerializationBinder Binder
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public virtual StreamingContext Context
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public virtual ISurrogateSelector SurrogateSelector
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public abstract void Serialize(Stream stm, object obj);
public abstract object Deserialize(Stream stm);
}
public class RawStringFormatter : BaseFormatter
{
public override void Serialize(Stream s, object o)
{
RawString rs = (RawString)o;
byte[] ba = rs.ToByteArray();
s.Write(ba, 0, ba.Length);
}
public override object Deserialize(Stream stm)
{
StreamReader sr = new StreamReader(stm, true);
string s = sr.ReadToEnd();
return new RawString(s);
}
}
[CustomFormatter(typeof(RawStringFormatter))]
[Serializable]
public class RawString
{
[XmlIgnore]
string _val;
public RawString(string s)
{
if (null == s)
throw new ArgumentNullException();
_val = s;
}
public RawString()
{
}
public byte[] ToByteArray()
{
return Encoding.UTF8.GetBytes(_val);
}
public override string ToString()
{
return _val;
}
}
}

  1. Then in a message assignement shape, type the following expression:
    (POMessageOut is the outgoing message, POMessageIn is the message you want to attach).

POMessageOut.BodyPart = new Microsoft.Samples.BizTalk.XlangCustomFormatters.RawString("This is the body of the email.");
POMessageOut.AttPart = POMessageIn;

  1. That's pretty much it!

Monday, February 4, 2008

Working with the SQL Adapter (Tutorial)

Ever wondered how to work with the SQL Adapter in BizTalk? Below is a complete tutorial to teach you about it! It contains parts about retrieving information, polling the database, updating the database and debatching the results.

Download the file.

Monday, January 28, 2008

Convert Xmlmessage to Word 2007 Format (OOXML)

While I was doing some research on custom pipeline components, I came accross an example of a sendpipeline that encodes a message to the new Open Format OOXML of Word 2007.
You can download the sample here: CreateOOXMLPackage.zip

Just build the solution, and add the Pipeline dll to the "C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components" folder and also to the GAC.
Add a Reference from the BizTalkProject to the pipeline.
Deploy the BizTalkProject with the appropiate properties.

In the BizTalkAdministration Tool, create a Receive and a Send Port, both using the FILE-adapter. Set the Send Pipeline to "CreateOOXMLPackage" and configure the destination filename to be something like "documentname.docx".
Also set a filter on the Send Port to subscribe to the Receive Port.
And configure the Outbound Maps to use SalesReport_to_WordMLSalesReport.

Now drop a testfile into the Receive Location and let the pipeline work its magic!

Credit goes to Nick Heppleston and his BLOG.

Exception Handling in Orchestrations

It might be basic knowledge for some, but for a BizTalk-newbie it can be useful information... ;-)

If you want to access the error message in a catch-block, you should do it like this:
  1. Set the "Exception Object Type" of the catch-block to "System.Exception" (can be found in the mscorlib).
  2. Set the "Exception Object Name" of the catch-block to "ex".
  3. In any expression inside the catch-block, you can now use code such as ex.Message, ex.StackTrace, ...

If you want to throw a new exception, you can use the ThrowException shape. This shape can be a little confusing though. It has an "Exception Object" property which you assign using a drop-down list. When you first drag the shape onto your orchestration, the only item in the list is "General Exception". If you wish to throw a specific exception, you need to create a variable of an exception type. This variable will then be displayed in the drop-down list.

Calling a WebService from an Orchestration (Tutorial)

I'll start things of here by posting a tutorial on how to call a webservice from an orcherstration.
Download the files below, one is the actual tutorial (in pdf format) the other is the accompaniing source code:

Enjoy!