Extending the BizTalk ESB Toolkit - Orchestration

Recently, I have been doing some work with the ESB Toolkit. I needed
to use an orchestration as an itinerary service, and while there is some
documentation on how to build an orchestration that can be used as an
itinerary service, there is nothing in the documentation that shows how
to get your custom orchestration to show up in the itinerary designer.
After spending some time pulling my hair out trying to get this to work,
I managed to stumble upon this blog post and this video that
outline the steps necessary to make a custom orchestration available in
the itinerary designer.

Without further ado, here is what it takes to create a custom
orchestration for use with the ESB Toolkit.

Create your Itinerary Service Orchestration

  1. Add the following references to your orchestration project:

    • Microsoft.Practices.ESB.Itinerary
    • Microsoft.Practices.ESB.Itinerary.Schemas
    • Microsoft.Practices.ESB.ExceptionHandling
    • Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults
  2. Add a logical direct-bound receive port and a receive shape with the
    “Activate” property set to true to your orchestration.

  3. Set the receive shape filter expression to subscribe to the
    itinerary context properties:

  4. Create orchestration variables of type
    Microsoft.Practices.ESB.Itinerary.IItinerary and
    Microsoft.Practices.ESB.Itinerary.IItineraryStep. Use an expression
    shape to get the current itinerary.

1
2
3
4
5
itineraryWrapper = new Microsoft.Practices.ESB.Itinerary.SerializableItineraryWrapper();
itineraryStepWrapper = new Microsoft.Practices.ESB.Itinerary.SerializableItineraryStepWrapper();

itineraryWrapper.Itinerary = Microsoft.Practices.ESB.Itinerary.ItineraryOMFactory.Create(msgInbound);
itineraryStep = itineraryWrapper.Itinerary.GetItineraryStep(msgInbound);
  1. Add your custom logic to the orchestration.
  2. Advance the itinerary to the next step and attach it to the outbound
    message.
1
2
msgOutbound(*) = msgInbound(*);
itineraryWrapper.Itinerary.Advance(msgOutbound, itineraryStepWrapper.ItineraryStep);
  1. Send the outbound message to the message box using a direct-bound
    send port.

Add your Orchestration to the Itinerary Designer

  1. Open the Esb.config file in the ESB Toolkit installation directory
    and add a new itineraryService element with the following
    attributes:

    • id: A GUID to identify the new service minus the curly braces.
    • name: The assigned name for your orchestration. This will be the
      name that shows up in Visual Studio and it used by the filter
      expression.
    • type: The fully qualified type name of the orchestration.
    • scope: Since this is an orchestration it should be set to
      Orchestration.
    • state: None

    Example:

1
2
3
4
5
6
7
8
9
<itineraryservice id=”0f8fad5b-d9cb-469f-a165-70867728950e”
name=”SD.DO2.PRM.MyOrchestation”
type=”SD.DO2.PRM.Orchestrations.MyOrchestration,
SD.DO2.PRM.Orchestrations,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=274da52117eafef4”
scope=”Orchestration”
stage=”None” />