Monday, April 07, 2008

Reverse Engineering BizMaps in BizTalk

Interesting trick with BizTalk Maps.   The Mapping Editor uses XML in the background.  For manipulating maps, use the Open With shortcut to your favourite XML editor.  i.e. Notepad.

Notice below that there are ID's set for individual Functoids.  These functoids are stored in C:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Microsoft.BizTalk.BaseFunctoids.dll

Looking at this class library in Reflector, you can browse to get the ID of the functoid under Base.ID.   For the StringLeftFunctoid() class it is 0x66.  It is stored as hex, so dropping the 0x and converting the value to decimal using http://www.easycalculation.com/hex-converter.php gives you 102.

By further reverse-engineering of the BizTalk.BaseFunctoids.dll library, you can see some different styles of implementing the various functoids.

If you don't like working with design tools for maintenance and simple things like changing base functoids, then you can modify this file, at the risk of blowing everything up.

Now if only you could do this mapping in Visio... and execute it... now that would be a powerful Data Design/ETL/Workflow tool.

<?xml version="1.0" encoding="utf-16"?>
<!-- Generated using BizTalk Mapper on Mon, Apr 07 2008 02:03:28 PM -->
<mapsource Name="BizTalk Map" BizTalkServerMapperTool_Version="2.0" Version="2" XRange="100" YRange="420" OmitXmlDeclaration="Yes" TreatElementsAsRecords="No" OptimizeValueMapping="Yes" GenerateDefaultFixedNodes="Yes" PreserveSequenceOrder="No" CopyPIs="No" method="xml" xmlVersion="1.0" IgnoreNamespacesForLinks="Yes">
  <SrcTree>
    <Reference Location=".\KeyStats.xsd" />
  </SrcTree>
  <TrgTree>
    <Reference Location=".\KeyStats_2.xsd" />
  </TrgTree>
  <ScriptTypePrecedence>
    <CSharp Enabled="Yes" />
    <ExternalAssembly Enabled="Yes" />
    <VbNet Enabled="Yes" />
    <JScript Enabled="Yes" />
    <XsltCallTemplate Enabled="Yes" />
    <Xslt Enabled="Yes" />
  </ScriptTypePrecedence>
  <TreeValues>
    <TestValues />
    <ConstantValues />
  </TreeValues>
  <Pages>
    <Page Name="Page 1">
      <Links>
        <Link LinkID="1" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='ShortName']" Label="" />
        <Link LinkID="2" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='Exchange']" Label="" />
        <Link LinkID="3" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='IndustryName']" Label="" />
        <Link LinkID="4" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='FCFF']" Label="" />
        <Link LinkID="5" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='FCFE']" Label="" />
        <Link LinkID="6" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='MarketCap']" Label="" />
        <Link LinkID="7" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='MarketCap_USD']" Label="" />
        <Link LinkID="8" LinkFrom="1" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='FirmValue']" Label="" />
        <Link LinkID="9" LinkFrom="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='KeyStats_Child1']" LinkTo="2" Label="" />
        <Link LinkID="10" LinkFrom="2" LinkTo="/*[local-name()='&lt;Schema&gt;']/*[local-name()='KeyStats']/*[local-name()='Symbol']" Label="" />
      </Links>
      <Functoids>
        <Functoid FunctoidID="1" X-Cell="56" Y-Cell="215" Functoid-FID="376" Functoid-Name="Nil Value" Label="">
          <Input-Parameters />
        </Functoid>
        <Functoid FunctoidID="2" X-Cell="56" Y-Cell="212" Functoid-FID="106" Functoid-Name="String Extract" Label="">
          <Input-Parameters>
            <Parameter Type="Link" Value="9" Guid="{5AE7B85F-255C-498D-BF5C-1F1DBABF180B}" />
            <Parameter Type="Constant" Value="1" Guid="{7DF87C5C-729A-4726-B4E7-F51FD52CC659}" />
            <Parameter Type="Constant" Value="3" Guid="{80449EC2-724D-45E8-B64F-67EA60B42D94}" />
          </Input-Parameters>
        </Functoid>
        <Functoid FunctoidID="3" X-Cell="53" Y-Cell="213" Functoid-FID="101" Functoid-Name="String Find" Label="">
          <Input-Parameters />
        </Functoid>
      </Functoids>
    </Page>
  </Pages>
</mapsource>

No comments: