Category nameļ¼šBizTalk

MULTILINE EXEC : BizTalk deployment (BTDF), or a gotcha in MSBUILD don’t know but there is a workaround….

October 18, 2013 / Comments Off on MULTILINE EXEC : BizTalk deployment (BTDF), or a gotcha in MSBUILD don’t know but there is a workaround….

I use the BizTalk Deployment Framework (BTDF) a lot for deployment of BizTalk solutions.
BTDF is using MSBUILD tasks to deploy a assembly.

Last week we found a problem with deployment of a specific solution. The problem was MS-BUILD was not performing as expected.
We had a task that looked like this…..

     Command=”&quot;$(BtsDir)Trackingbm.exe&quot; add-account -View:&quot;%(BAMViewsAndAccountsGroup.viewName)&quot; -AccountName:&quot;%(BAMViewsAndAccountsGroup.groupNames)&quot;”
     ContinueOnError=”true” Condition=”‘$(BAMViewsAndAccounts)’ != ””/> 

The command would fail but since ContinueOnError was set to true the build would continue as if nothing had happened.
However… This build above was called by another build. And the original toplevel build would still fail !!!

I have looked everywhere and after a lot of googeling finally I found that the MsBuild task EXEC is by default MULTILINE….

This solved my problem very quickly. I changed the command to:

     Command=”&quot;$(BtsDir)Trackingbm.exe&quot; add-account -View:&quot;%(BAMViewsAndAccountsGroup.viewName)&quot; -AccountName:&quot;%(BAMViewsAndAccountsGroup.groupNames)&quot; > null
                             Exit 0
     Condition=”‘$(BAMViewsAndAccounts)’ != ””/> 

And now the build complestes with succes.
Not the most elegant solution but it does the job…


Something you REALLY should know about dates ! (beeing Kind to DateTime.Kind)

September 2, 2011 / Comments Off on Something you REALLY should know about dates ! (beeing Kind to DateTime.Kind)

Here we go, some important stuff about dates…..(it’s not only BizTalk related)

I had a very simple scenario.

  1. Webservice Receives a request (with several datetime fields in it)
  2. Send the received message to SQL via the WCF adapter

For some obscure reason some datetime values  originating from the same WebRequest got modified once in the database and some did not. 
After some tracing we found that the dates were serialized in a different way once inside the webservice.
some of the formats we saw :

  • 2011-08-29T18:00:00.826;
  • 2011-08-29T18:00:00
  • 2011-08-29T18:00:00.3983714
  • 2011-08-29T18:00:00Z

All these got to the database unchanged, but we also saw datetime like below

And these datetime fields got calculated back to their UTC time and were then stored in the database.

After some experimenting we found the following interesting stuff…..

Datetime.Kind (but for sure, everybody already knew that)…. So what is this KIND ?

Public property Supported by the XNA Framework Supported by Portable Class Library Kind Gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither.

So what happens is the following, 

  • Create a DateTime in code (like DateTime current = DateTime.Now) and Kind is Local
  • Create a DateTime in code and Assign a database field (like DateTime fromdb = datetimefield from database) and Kind = Unspecified

And what’s the difference ?

Well the difference is that when the WCF Adapter stores the date to the database field.

  • when != to unspecified it calculates it back to UTC
  • when == unspecified it is stored as is….


Since I really wanted unified DateTimes in the complete solution I created a pipeline that did the following trick:

        static string CreateUnspecifiedDate(string someXsDateTimeString)
           DateTimeOffset dto = DateTimeOffset.Parse(someXsDateTimeString);
           DateTime res = dto.LocalDateTime;
           return System.Xml.XmlConvert.ToString(res,System.Xml.XmlDateTimeSerializationMode.Unspecified);

And the problem was solved. But I did learn something about datetimes

Really nice BizTalk Admin tool, BizTalk 360

May 3, 2011 / Comments Off on Really nice BizTalk Admin tool, BizTalk 360

Today I stumbled upon a really nice BizTalk admin tool. (thanks google reader)

Have a look at it >>here<<

It’s a kind of Silverlight BizTalk Administration console with quite a few extra’s.
Really good work !

Removing unwanted namespaces from a BizTalk Map

March 10, 2011 / Comments Off on Removing unwanted namespaces from a BizTalk Map

BizTalk is a great tool but sometimes the output is a little unreadable because of the number of namespaces in a document.
This post is related to a previous post where I had to import a zillion schemas. Once I had those schema’s imported I could map them but the ouput looked as the picture below.

So about 120 namespace declarations and then some data. (the namespace declaration was about 10K and the message itself only 5K) This was not what the customer desired and they wanted to get rid of some (most) of those namespaces.
So I created a nice little CSLT that would get rid of those namespaces. I started a discussion on MSDN <clickto see> and Greg Forsythe came with the following solution.
Create a custom XSLT like this :

<xsl:stylesheet xmlns:xsl= version=1.0>
   <xsl:template match=*>
      <xsl:element name={local-name()} namespace={namespace-uri()}>
         <xsl:apply-templates select=@* | node()/>
<xsl:template match=@* | text() | comment() | processing-instruction()>

And surely that did the trick.
But there was a problem. I now had to execute two maps. One to map to the desired output and one to get rid of all those namespaces.
Furthermore this script had the problem that instead of declaring all the namespaces once at the top of the document, it repeated the namespaces in every node, resulting in a much less readable message.

Leg xmlns=”urn:fec:florecom:xml:data:draft:ReusableAggregateBusinessInformationEntity:3“>
        <TypeCode xmlns=”urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:3” listID=”Recommendation 28″ listAgencyID=”6″ listVersionID=”2007″/>
        <CountryID schemeVersionID=”second edition 2006″/>

After googling around I came to a solution where I had the following problems solved.

  • No extra map required
  • Namespaces declared only once per message
  • High level of control of what namespace to declare and what namespace to omit.

Here is how I did it :

  • First Create the map as you normally do.
  • Then after the map is finished, select validate map.
  • You will be presented with something like this :

 D:Lokale BestandenOntwikkelingCEFH.CEFH.CCE.CCX.Plugins.XMLLB_v0006FH.CCE.CCX.Plugins.XMLLB_v0006MapsGeleverdePartij_v0006_To_Delivery_0p2.btm: warning btm1004: The destination node “TypeCode” has multiple inputs but none of its ancestors is connected to a looping functoid.
D:Lokale BestandenOntwikkelingCEFH.CEFH.CCE.CCX.Plugins.XMLLB_v0006FH.CCE.CCX.Plugins.XMLLB_v0006MapsGeleverdePartij_v0006_To_Delivery_0p2.btm: The output XSLT is stored in the following file:
file:///C:Documents and SettingspkwkLocal SettingsTemp1_MapDataGeleverdePartij_v0006_To_Delivery_0p2.xsl
D:Lokale BestandenOntwikkelingCEFH.CEFH.CCE.CCX.Plugins.XMLLB_v0006FH.CCE.CCX.Plugins.XMLLB_v0006MapsGeleverdePartij_v0006_To_Delivery_0p2.btm: The Extension Object XML is stored in the following file: <file:///C:Documents and SettingspkwkLocal SettingsTemp1_MapDataGeleverdePartij_v0006_To_Delivery_0p2_extxml.xml>

  •  Now test the map and see if it still gives the same result (it should)
  • Then open the Custom.xsl and look  for “exclude-result-prefixes
  • Then I added all the namespaces I wanted to exclude to this so it looked like this :


=msxsl var s2 s0 s1 userCSharp udt qdt ns1 ns2 ns3 ns4 ns5 ns6 ns7 ns8 ns9 ns10 ns11 ns12 ns13 ns14 ns15 ns16 ns17 ns18 ns19 ns20 ns21 ns22 ns23 ns24 ns25 ns26 ns27 ns28 ns29 ns30 ns31 ns32 ns33 ns34 ns35 ns36 ns37 ns38 ns39 ns40 ns41 ns42 ns43 ns44 ns45 ns46 ns47 ns48 ns49 ns50 ns51 ns52 ns53 ns54 ns55 ns56 ns57 ns58 ns59 ns60 ns61 ns62 ns63 ns64 ns65 ns66 ns67 ns68 ns69 ns70 ns71 ns72 ns73 ns74 ns75 ns76 ns77 ns78 ns79 ns80 ns81 ns82 ns83 ns84 ns85 ns86 ns87 ns88 ns89 ns90 ns91 ns92 ns93 ns94 ns95 ns96 ns97 ns98 ns99 ns100 ns101 ns102 ns103 ns104 ns105 ns106 ns107 ns108 ns109 ns110 ns111 ns112

  • That’s guite a list. And now if I test the map the result looks like the picture below :


  • And that’s exactly what the customer wanted.

I hope this Blog post will help other people wha are struggeling with the same problem. If it does, please leave a comment below.

XSLT Distinct another way to determine distinct in XSLT 1.0

February 17, 2011 / Comments Off on XSLT Distinct another way to determine distinct in XSLT 1.0

I had a requirement to map a buyer only if it was the same buyer throughout the entire document.
The reason for this was that in the source document the buyer was defined in a sub sub sub node of a document and in the destination it occurred only once.
So I ended up with several choices.

  • Only map the first buyer
  • Don’t map
  • Only map if they were the same throughout the entire document

For sure the first option would be a bad thing.
The second option would work for all parties involved (it’s an optional element in the output of the map) but the parties really want their buyer information if it’s there.
The third option seemed the best solution. I quickly googled on XSLT and distinct and there were some results. So I told the customer implementing a distinct wouldn’t be too hard. (it already existed in XSLT).
(I wish I looked a bit harder, cause then I would have seen that the distinct function of XSLT comes with XSLT 2.0 and sadly BizTalk is still using XSLT1.0)

After some thinking I got the following solution for this problem.

  1. Perform a count of the number of buyers in a document
  2. Get the first buyer (buyer is mandatory in the input document)
  3. Perform a count of the numbers of buyers where buyer != buyer found in step2

If the number in step 3 is 0 then we know all the buyers are the same. Below is the XSLT I used to perform this different distinct approach.

<xsl:template name=”Buyerparty_DocTemplate”>
  <xsl:param name=”var1″ />
  <xsl:param name=”var2″ />
  <xsl:param name=”dbg” />
  <xsl:variable name=”buyers” select=”count(/s0:Request/GeleverdePartij/LeveringsBericht/Levering[*]/Ladingdrager[*]/Goederen[*]/Koper/kop_gln)” />
  <xsl:variable name=”firstBuyer” select=”/s0:Request/GeleverdePartij/LeveringsBericht/Levering[1]/Ladingdrager[1]/Goederen[1]/Koper/kop_gln” />
  <xsl:variable name=”otherBuyers” select=”count(/s0:Request/GeleverdePartij/LeveringsBericht/Levering[*]/Ladingdrager[*]/Goederen[*]/Koper[not(kop_gln=$firstBuyer)])” />
  <xsl:if test=”$dbg=1″>
    <xsl:element name=”BuyerInfo”>
      <xsl:element name=”TotalBuyers”>
        <xsl:value-of select=”$buyers” />
      <xsl:element name=”FirstBuyer”>
        <xsl:value-of select=”$firstBuyer” />
      <xsl:element name=”OtherBuyers”>
        <xsl:value-of select=”$otherBuyers” />
  <xsl:if test=”$otherBuyers=0″>
    <xsl:if test=”string-length($firstBuyer) > 0″>
      <xsl:element name=”BuyerParty”>
        <xsl:element name=”PrimaryID”>
          <xsl:value-of select=”$firstBuyer” />
        <xsl:element name=”schemeID”>
          <xsl:value-of select=”$var1″ />
        <xsl:element name=”schemeAgencyName”>
          <xsl:value-of select=”$var2″ />

xs:int and xs:integer, what’s the difference….

February 8, 2011 / Comments Off on xs:int and xs:integer, what’s the difference….

I am busy creating schema’s and exposing them as a web service.
I always generate a client and try to post some messages and this time I was again surprised by BizTalk. (or should I say XML).
When creating a schema you can chose several types for an element. Some of these are xs:int and xs:integer.
I noticed these two before but didn’t bother too much.
But now for the first time I see there is a clear difference in the way stuff is treated by .Net. Below is a screenshot of a node with the type xs:integer.

I also have some regular elements of type xs:int. Below is a screenshot of that.

Now after I generated the WCF service for this schema, I imported the WSDL into VS 2005 and I was quite surprised to see what intellisense did to these elements in visual studio :

 So intellisense showed me it was actually a string !… And the other node of type xs:int was the .Net type I expected to see.

So what did I learn today, to stay away from xs:integer and use xs:int instead.
Hope this will help someone in the future, if it does, leave a comment


Download all files referenced in an xsd locally (+ Possible fix for BizTalk CS0013 compilation error)

September 30, 2010 / Comments Off on Download all files referenced in an xsd locally (+ Possible fix for BizTalk CS0013 compilation error)

Well if you ever end up like me with a XSD that has about a zillion includes (schemaLocation), maybe this tool is something for you.

It is a pretty simple tool. You give it an XSD, and it will download all files that are referenced to your local system. It will parse the file names a bit and set them all to the local download folder.
This way you can simply include the folders and downloaded schema’s in your BizTalk Project.

For example take the schema’s from UNECE like

It can be pretty frustrating to download all the schema’s manually and link them together again with a correct import. IncludeSchemaDownloader.exe comes to the rescue.. Below is a screenshot of this tool.

The workings are quite simple. Follow these steps to get the all the schema’s on yoyr local machine.

  1. Download the Toplevel XSD to a work folder.
  2. Point the Toplevel XSD to that working folder.
  3. Point the StoreFolder to the desired location where the xsd’s will be stored (typically schema’s folder of a BizTalk Project
  4. Hit the process button !
  5. Done
  6. Now include this folder in your BizTalk project
  7. Hit the Validate button… (should work)

Now these XSD schemas that you get from UNECE are full with usefull comments and annotations. And if your schema’s get too large you cannot compile them anymore. (there seems to be a limit in the size of the dll the BizTalk compile can handle). You would get an error message like this:

error CS0013: Unexpected error writing metadata to file ‘<somedrive><somefolders><yourproject>.dll’


To solve this you would have to break up your huge XSD project into smaller projects. This would solve the problem but in my case VisualStudio was soo busy reflectoring all the DLL’s it hardly had time for me. (You know opening a map would take ages….).

When I looked into the XSD’s they were all beautifully documented with lots and lots of annotations and comments. But wait a minute….. I only had to send these documents. So i only have to validate the documents. So I don’t need all those comments and annotations. That’s why the tool has the option to strip comments and annotations.

When I tried to compile the XSD’s with comments and annotations (size on disk roughly 12 megabytes) I got the dreaded  CS0013 compilation error.

I ran the tool again (size on dis now about 1.5 megabytes) I ended up with a DLL only 4 MB in size. And if reference this DLL in a map or whatever it’s way faster than the other solution(you know several projects / dll’s)

You can download the tool >>HERE <<

If I import the schema

The output of the tool will be  :

Starting with D:TempDemoAcknowledgement_4p0.xsd
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
getting all imports
Loading file :
This list goes on and on and on

 Below are some results:





Using XSLT Templates in a map (reminder@self)

August 16, 2010 / Comments Off on Using XSLT Templates in a map (reminder@self)

We all know that using XSLT inside a map can be very usefull to do stuff that’s very hard to do with the mapper itself.
Sometimes using XSLT it is the only way things can be done. I find myself struggeling each time to figure out how specific tasks work with XSLT.

That’s why I write this post. So I wont have to figure it all out again the next time i need this functionality….
Below is some code used in an ‘Inline XSLT Call Template’ to calculate the number of segments in a message (UNT) and the message Message Reference number.

The input CurrentIndex is retrieved from an Iteration functoid that returns the current index of the transaction. This index is used to retrieve the correct values for the UNT segment of that transaction
( I am using the batched EDI schema’s).

<xsl:template name=UNTTemplate>

  <xsl:param name=currentIndex />

  <xsl:variable name=sum01 select=count(/s2:Request/INTERCHANGE/UNB) />

  <xsl:variable name=sum02 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/UNH) />

  <xsl:variable name=sum03 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/BGM) />

  <xsl:variable name=sum04 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/DTM) />

  <xsl:variable name=sum05 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/NAD) />

  <xsl:variable name=sum06 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN) />

  <xsl:variable name=sum07 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/DTM) />

  <xsl:variable name=sum08 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/NAD) />

  <xsl:variable name=sum09 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/RFF) />

  <xsl:variable name=sum10 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/QTY) />

  <xsl:variable name=sum11 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/PRI) />

  <xsl:variable name=sum12 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/IMD) />

  <xsl:variable name=sum13 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/IMD/PRICE_INFORMATION) />

  <xsl:variable name=sum14 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/PAC) />

  <xsl:variable name=sum15 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/PAC/PRI) />

  <xsl:variable name=sum16 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/EQD) />

  <xsl:variable name=sum17 select=count(/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/LIN/EQD/EQN) />

  <xsl:variable name=unt18  select=/s2:Request/INTERCHANGE/TRANSACTION[position()=$currentIndex]/UNH/MESSAGE_REFERENCE_NUMBER />

  <xsl:variable name=totalCount select=$sum01 + $sum02 + $sum03 + $sum04 + $sum05+ $sum06 + $sum07 + $sum08 + $sum09 + $sum10 + $sum11 + $sum12 + $sum13 + $sum14 + $sum15+ $sum16 + $sum17 />

  <xsl:element name=UNT>

    <xsl:element name=UNT1>

      <xsl:value-of select=$totalCount />


    <xsl:element name=UNT2>

      <xsl:value-of  select=$unt18 />





Again a BizTalk Hotrod issue you should not miss

July 29, 2010 / Comments Off on Again a BizTalk Hotrod issue you should not miss

Last week I stumbled upon the Tenth issue op BizTalk HotRod. I have looked into it a couple of times cause there are so much goodies in there.
The items covered in this issue are: 

  • Creating Business Documents 
  • Automating deployments of BizTalk change requests
  • Request and Response Message Pattern
  • Instrumentation Best Practices for High Performance BizTalk Solutions
  • Financial Messaging Service Bus
  • How To Boost Message Transformations Using the XslCompiledTransform class

 Go and get this issue, you can download it >>HERE<<

Interessante Blog Postings

June 30, 2010 / Comments Off on Interessante Blog Postings

Gedurende een bepaalde periode kom je op het internet interessante zaken tegen of zijn er interesante blogpostings gedaan. Soms google je wat en kom je een oude maar zeer interessante blogposting tegen. In dit artikel wil ik een aantal van deze blogpostings/blogposters/artikelen aanstippen.


Maxime Labelle


Heeft een interessant blog waar hij af en toe diep ingaat op de werking van BizTalk. Er zitten veel code voorbeelden bij. Enkele noemenswaardige zaken zijn onder andere:

A Base Class for Building Custom Pipeline Components

Een handige base class welke het leven van een BizTalk ontwikkelaar behoorlijk kan versimpelen. In plaats van iedere keer weer alles van de grond af aan op te bouwen zorgt deze base class standaard voor een aantal zaken. Je hoeft eigenlijk alleen nog maar de Execute van de pipeline te programmeren. Erg handig.

Streaming Data in and out of an SQLServer 2005 Database

Interessant artikel over het opslaan van BizTalk Berichten in een database. Absoluut de moeite van het lezen waard.


Als je nog wat verder snuffelt op zijn blog zul je zien dat er echt interessante en nuttige zaken tussen staan.


Validatie functie BizTalk


Gebruikers van de “BizTalk Best Practice” zullen wel weten dat ik een groot voorstander ben van het valideren van xml nadat er gemapped is. Een map biedt immers geen enkele garantie met betrekking tot het valide zijn van het resultaat. Voorheen gebruikte ik daarvoor altijd de ‘Cool XSD Validation Function for Orchestration van de ‘Arch Hacker’ . Deze validatie functie is inmiddels stokoud en compileert niet zonder warnings meer in .Net 2.0 en hoger. Met een aantal ‘Pragma Directives’ kon het nog net compileren zonder warnings maar dat de code ondertussen sterk verouderd is blijft een feit. Onlangs kwam ik een nieuwe versie tegen die wel voldoet aan 2.0. Daarnaast biedt deze wat meer functionaliteit.


BizTalk Service Pack 1, Fix Pack1, Fix Pack 2 !


Begin dit jaar is voor BizTalk Service Pack 1 uitgerold en zodra deze geïnstalleerd was op de ontwikkel server van de klant waar ik op dit moment zit werkte zaken niet meer zoals ze zouden moeten werken. Omdat dit bij Microsoft Support liep was ik op de hoogte van een BizTalk 2006 R2 SP1 Cumulative Update 1. Hierin waren een aantal zaken opgelost, maar het belangrijkste issue stond nog steeds open. Zeer onlangs kreeg ik te horen dar er nu ook een BizTalk 2006 R2 SP1 Cumulative Update 2 beschikbaar is. Blijkbaar was Service Pack 1 niet de meest geslaagde update uit de BizTalk geschiedenis.



  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta