GD Bloggers

This is the blog site for Microsoft Global Delivery Communities focused in sharing the technical knowledge about devices, apps and cloud.
Follow Us On Twitter! Subscribe To Our Blog! Contact Us

August, 2013

  • BizTalk Cop installation and configuration for VS 2012

    I faced a requirement today that I need to enable some BizTalk best practices and create a custom check-in policy for these practices while the developers are checking in code. While searching the internet I found the BizTalk Cop (which is a great tool) that does exactly that, but unfortunately this tool supports only Visual Studio 2010 and BizTalk 2010 and does not support BizTalk 2013 and visual studio 2012. So the challenge was how to enable this to work with Visual Studio 2012. Another challenge that I had was to create a default custom check-in policy and a rules set that is enabled by default on TFS that would only allow the developers to check-in their code if they enable this rule set.

    The solution that I performed involved the following changes (updates)

      1. I copied the DLL “BizTalkCop.Rules.dll” to the folder “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop\Rules”
      2. I created a file called “BizTalkRules.ruleset” (attached at the end of this article) containing the set of rules that are enabled by default for the projects.
      3. I copied the file “BizTalkRules.ruleset” to the folder “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\Rule Sets”
      4. Changed the file “devenv.exe.config” in the folder “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE” so that it redirects all FxCop dependencies from the 10.0 and 9.0 versions to the 11.0 version in the assembly binding section as follows:

    <dependentAssembly>
      < assemblyIdentity name="FxCopCommon" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>
    < dependentAssembly>
      < assemblyIdentity name="FxCopSdk" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>
    < dependentAssembly>
      < assemblyIdentity name="Microsoft.Cci" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>
    < dependentAssembly>
      < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>
    < dependentAssembly>
      < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>
    < dependentAssembly>
      < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis.Interop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
      < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
    < /dependentAssembly>

      1. Changed the file “FxCopCmd.exe.config” in the folder “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop” so that it redirects all FxCop dependencies from the 10.0 and 9.0 versions to the 11.0 version in the assembly binding section as follows:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      < dependentAssembly>
        < assemblyIdentity name="FxCopCommon" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name="FxCopSdk" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name="Microsoft.Cci" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name="Microsoft.VisualStudio.CodeAnalysis.Interop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        < bindingRedirect oldVersion="9.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
    < /assemblyBinding>

    1. Restart VS 2012
    2. I enabled a default check-in policy using the source control settings as per the below screen shoots
      image
      image
      image
      image
    3. Make sure you perform the same steps on the TFS Build server and all developer machines.

     

     

     

    Happy coding :)

     

  • Solved: Nested and conditional parent and child Table Looping Functoid in BizTalk mapping

    Introduction

    BizTalk mapping tool is a very powerful tool once you get the hang of it. Sometimes you would need to produce some structure in the output schema that did not exist in the source schema, the Table Looping functoid is built for this specific task.

    In some other cases you would need to generate a parent child kind of structure. In this blog post I will present the solution to use out of the box functoids to be able to generate this structure.

    Problem

    Suppose you have the following as the input schema.

    clip_image002

    And the following output schema.

    clip_image004

    The requirement is to generate two Message elements in the ProcessRoot output schema. It is also required to generate some fields in the fields array inside each message. These fields are specific for each message and depend on the message ID field. So to be more specific let’s say that we have the following XML input:

    <ns0:ProcessRequest xmlns:ns0="http://BTSTest.InputSchema">

      <Parameter>Parameter_0</Parameter>

    </ns0:ProcessRequest>

    And we want to generate the following XML output from it:

    <ProcessRoot ID="9843748">

      <Message MessageID="ID1">

        <Entity EntityName="GM">

          <Field Name="code" Value="Val" />

          <Field Name="text" Value="txtval" />

          <Field Name="key" Value="Parameter_0" />

        </Entity>

      </Message>

      <Message MessageID="ID2">

        <Entity EntityName="GM">

          <Field Name="text" Value="Parameter_0" />

        </Entity>

      </Message>

    </ProcessRoot>

    As you can see we have two challenges:

    1-     You need to create not just an array of two messages for one node in the input message, but also some sub-fields within each message.

    2-     The fields generated are dynamic and dependent on the value of one of the fields of parent array.

    Solution

    Because I want to generate some structure that does not exist in the original message then we have to use the Table Looping and Table Extractor functoids. Now the challenges listed above is the key here on how to develop this. So I had many ways I tried to implement this but mainly they all involved creating two Table looping functoids one for the parent structure and one for the child array. The challenge I had was how to link them and make the second table looping functoid dependent on the first one. Here is the map I ended up implementing:

    clip_image006

    There are some key points here to consider.

    First the first table looping functoid generates the parent array of messages and hence it is linked to the output node of the messages as per this figure:

    clip_image008

    Also the table of this functoid has the following structure to be generated:

    clip_image010

    The second notice here is that we have a link from the first column of the parent table looping functoid and the first column also of the child table looping functoid linked to the output fields array to make the generation of the fields conditional if it is equal to the message ID of its parent. This means that second table looping functoid has to include the message ID as part of the table also it will not be generated in the output.

    clip_image012

    Now ideally this would mean that the table of the child table looping functoid should be as follows:

    clip_image014

    But when I tried this it never worked (and until now I do not know why) when I debugged the generated XSLT I noticed that the first two rows generated from this functoid are always wrong. When performed further testing I noticed that the child functoid always has bad rows generated out of it that are exactly equal to the number of rows generated from the first table looping functoid. So what I ended up doing is that I added two extra dummy rows that I made sure will never generate anything in the output schema by making sure that the value that would be compared is always not equal. So what I ended up doing is configuring the second table looping functoid as follows.

    clip_image016

    This achieved exactly what I wanted and produced the required output XML.

    The sample input schema, output schema, and the above described map can be found here.

    Happy BizTalking J