Friday, 18 September 2009

Hi all

I am REALLY excited to announce, that I will be co-authoring a book on BizTalk. I will be a part of a terrific team consisting of

  • Anush Kumar
  • Brian Loesgen
  • Charles Young
  • Jon Flanders
  • Scot Colestock
  • Tom Canter
  • Me :-)

Together we will be writing “BizTalk Server 2009 Unleashed”, which is so new, that you cannot find it on the web page of the publisher or any other sites. It is so new, that we haven’t even signed our contracts with the publisher yet, which may cause someone to quit the project if they are not happy about the contract… so nothing promised yet.

But, needless to say, I am really excited, and giving the team, also feeling quite humble :-).

This will be my first book.

Wohooo

--
eliasen

Friday, 18 September 2009 22:06:38 (Romance Daylight Time, UTC+02:00)  #    Comments [11]  | 

Hi all

So, sorry to see it, but it appears it has been almost two months since my last blog post – hope to get back on track soon.

Since the last time, I have installed Windows 7 RTM on my laptop, and one of the reasons I haven’t blogged is, that I couldn’t get Windows Live Writer Backup to restore my backup of Windows Live Writer from my old Windows XP installation. That turned out to be a silly thing… For others; You cannot restore using WLW Backup without having run Windows Live Writer first. It isn’t enough to install it, it must have been run also. Oh well.

 

I hope to entertain you all some more from now on…

 

--
eliasen

Friday, 18 September 2009 21:55:49 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 

Hi all

Some weeks ago, I had a customer that had an Order XML and needed to fetch all the names of the ordered items based on the item number that was in the XML.

He contacted me because the solution he had thought of didn’t work. What he did was that he mapped the Order XML to a SQL Adapter schema that called an SP in SQL Server to get the item name based on the item number. The issue he ran into was, that the SP got called multiple times – once for each item, and the SQL adapter didn’t seem to batch all the results into one result for his orchestration.

So, given this simplified Order:

<ns0:Order xmlns:ns0="http://MultipleCallsToSP.Order">
  <Header>
    <CustomerName>CustomerName_0</CustomerName>
    <OrderNumber>OrderNumber_0</OrderNumber>
  </Header>
  <OrderLines>
    <OrderLine>
      <ItemNumber>21</ItemNumber>
      <Quantity>42</Quantity>
    </OrderLine>
    <OrderLine>
      <ItemNumber>42</ItemNumber>
      <Quantity>21</Quantity>
    </OrderLine>
  </OrderLines>
</ns0:Order>

He mapped it to this XML:

<ns0:GetItemNameRequest xmlns:ns0="http://eliasen.dk">
  <ns0:GetItemName ItemID="21" />
  <ns0:GetItemName ItemID="42" /> 
</ns0:GetItemNameRequest>

This was then sent to SQL Server using the SQL Adapter to call a SP named “GetItemName” which just takes an ItemID (int) as parameter and returns the ItemName hat matches the ItemID.

Now, the schema that is generated for the SQL Server request actually doesn’t allow for multiple GetItemName elements to be created, but that is changeable :-) If you set it to have maxOcurs = unbounded, then it can occur multiple times, and what happens is that the SP is called multiple times. Unfortunately, only one of the ItemNames is returned – the rest is ignored.

So the customer came to me because naturally, he needed all the ItemNames and not just one of them. I have suggested 5 possible solutions, which I will describe here.

First option
Use the pattern described at http://blog.eliasen.dk/2006/11/05/LoopingAroundElementsOfAMessage.aspx to loop around the order lines and build the resulting XML one order line at a time.

Second option
Use enveloping in the receive location in order to get one orchestration started for each order line.

Third option
Use the Database Lookup functoid to retrieve the ItemName based on the ItemID

Fourth option
Generate a comma separated list of ItemID’s in the map, and let the stored procedure use that list to return the relevant ItemNames. This has some consequences for the stored procedure. Before it looked like this:

SELECT ItemNumber, ItemName
FROM Items
WHERE Items.ItemNumber = @ItemID
FOR XML AUTO, ELEMENTS

Now, it looks like this:

SELECT ItemNumber, ItemName
FROM Items
WHERE EXISTS (select * from dbo.Split(‘,’,@items) where [Items].ItemNumber = ID)
FOR XML AUTO, ELEMENTS

@items is the parameter for the SP, which is just an nvarchar that is to contain the comma separated list.

For this to work you need the Split function, which looks like this:

CREATE FUNCTION [dbo].[Split] (@sep char(1), @s varchar(512))
RETURNS table
AS
RETURN
(    
                WITH Pieces(pn, start, stop) AS (
                      SELECT 1, 1, CHARINDEX(@sep, @s)
                      UNION ALL      
                      SELECT pn + 1, stop + 1, CHARINDEX(@sep, @s, stop + 1)      
                      FROM Pieces      
                      WHERE stop > 0    
                 )
                 SELECT pn, CONVERT(int, SUBSTRING(@s, start, CASE WHEN stop > 0 THEN stop-start ELSE 512 END)) AS ID
FROM Pieces
)

In order to generate the comma separated list in your map, I have written two blog posts about this issue, which you can find at http://blog.eliasen.dk/2009/06/22/HandlingCommaSeparatedValuesInsideAMapPartI.aspx and http://blog.eliasen.dk/2009/06/27/HandlingCommaSeparatedValuesInsideAMapPartII.aspx

Fifth option
The fifth and last option i want to mention is, that with the new SQL Server LOB adapter from Adapter Pack 2.0, it appears that you can do it like the customer wanted to do it in the first place with sending one XML to SQL Server and getting an accumulated response back from SQL Server based on several calls to a stored procedure. I haven’t had time to test this, but look out for another blog post about this :-)

 

Hope this helps someone.

 

--
eliasen

Friday, 18 September 2009 21:47:51 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 
Tuesday, 28 July 2009

Hi all

Just to let you know, I am now listed on http://www.biztalkblogs.com along with lots of other cool BizTalk bloggers :-)

--
eliasen

Tuesday, 28 July 2009 17:40:29 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 
Thursday, 23 July 2009

Hi all

I have just released version 5 of my pipeline components library.

It has the following additions:

  • SuspendAfterMap. In BizTalk 2009 (which is the only supported BizTalk version for this pipeline component) there has been added support for recoverable interchanges for errors occurring during mapping on receive ports after disassembling. This is achieved by setting a specific promoted property to “true”. I have created a pipeline component that will do this for you.
  • WriteProperties. This pipeline component serves almost NO purpose at all, except I used it for debugging to see what properties existed on a message going through BizTalk. It will write out all context of a message to the eventlog, one event at a time.

It has the following new features:

  • Promote. The pipeline component used for promoting a value based on an XPath expression and thereby enabling you to promote a specific instance of a reoccurring element has been enhanced by a “constant”. So instead of having to set the value of some property to the result of an XPath expression you can just enter a constant instead. If you enter both a constant and an XPath expression the constant wins. This new feature is quite handy if you need to set the value of for instance MIME.FileName to a specific value or any other property for that matter.

You can find the newest versions at http://eebiztalkpipelinecom.codeplex.com/

--
eliasen

Thursday, 23 July 2009 00:26:18 (Romance Daylight Time, UTC+02:00)  #    Comments [2]  | 
Wednesday, 22 July 2009

Hi all

I have just released version 9.1 of my functoid library. Actually, nothing much new has appeared. I had accidentally left out the functoid I described at http://blog.eliasen.dk/2009/03/08/SolvingTheIfThenElseProblemInAMapPartIII.aspx from version 9, so now it is reintroduced – and it has also been added to the documentation.

Find the newest version of the functoids library at http://eebiztalkfunctoids.codeplex.com – thanks.

--
eliasen

Wednesday, 22 July 2009 23:59:05 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 
Tuesday, 21 July 2009

Hi all

I have been running into too many issues with BizTalk 2009 on VS.NET 2008 lately. This post is just to mention them and let everyone else know that they are not the only one – and that they will be reported to MS and hopefully fixed quickly.

Build action of schemas
Some times the “build action” of a schema in your BizTalk project is set to “None” instead of “BtsCompile”. When this happens, the schema is not compiled into the assembly and can therefore not be used for pipeline components, maps, orchestration messages, and so on. It happens if you drag a schema from your explorer into your project, but it also happens sometimes when you drag a schema between two projects inside VS.NET.

More build action of schemas
The above error could be more easy to live with, if it weren’t absolutely impossible to know when the “Build action” property of the schema in visible in VS.NET – some times the property is visible and you can change the value. Other times it is not. Quite confusing. I have found that if I add a schema to a project, then the property is suddenly visible for all schemas in the project. Change the ones that need changing and delete the schema you added.

Auto save a map before schemas are chosen
When you add a new map then at some point VS.NET auto saves the map, but if this happens before you have chosen both the source and destination schema you suddenly get an error, which you really do not expect, because you weren’t doing anything at the time of the error. This also occurred in previous versions of BizTalk.

Map looses information about schemas
I have seen several times, that even after choosing source- and destination schema for a map and dragging a couple of links in the map and saving it, then at compile time, I get an error about the map not having source- and destination schemas. So I need to choose them again, and redo all the links, because they have magically disappeared. This happens for maps that uses both schemas from the same project as schemas from referenced projects.

Output window
The output window seems to not always show all information when compiling/deploying. Some times the information comes all at the end instead of being written to the output windows as it happens. Other times, I can rebuild my entire solution and the output windows will only show me the one warning that occurred during compilation.

Dragging elements in Schema Editor
Dragging elements inside the schema editor has had me baffled since BizTalk 2002. Some times, I need more than 20 tries to get an element to be dragged – and sometimes it just works. Annoying? Indeed it is!

Copy local fails
If I have a project (P2) that references another project (P1), then after I have added an item to P1 and recompiled it, everything seems OK. BUT, if I then deploy from within V.NET, things start to go wrong. From then on, it seems that the “Copy local” property of the project reference is ignored. Whenever I recompile P2, I do NOT get the P1.dll copied to the local folder of P2. This causes all sorts of stuff as also explained here by Ryan: http://dotnet.org.za/ryancrawcour/archive/2009/07/17/biztalk-2009-amp-visual-studio-2008-annoyance-2.aspx

Setting properties for more than one project at the same time
See here: http://dotnet.org.za/ryancrawcour/archive/2009/07/15/biztalk-2009-feature-missing.aspx for Ryans thoughts on this.

--
eliasen

Tuesday, 21 July 2009 22:22:24 (Romance Daylight Time, UTC+02:00)  #    Comments [12]  | 

Hi all

Microsoft have finally released some pricing information about Azure. Find it here: http://www.microsoft.com/azure/pricing.mspx

--
eliasen

Tuesday, 21 July 2009 17:43:40 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 
Wednesday, 15 July 2009

Hi all

I did a follow up to my old post about how to loop around the elements of a message a couple of days ago.

As you can se from the comments to my followup, Thiago mentions that there isn’t any performance hit because everything is done inside an atomic scope. Now, Thiago is naturally correct when he states, that no persistence occurs inside an atomic scope. But as you can also see from the comments, I wondered about what to do about using a request-response port – so I just had to test it.

For BizTalk 2009, just as the previous versions, you CAN’T have both the send shape and corresponding receive shape used for a request-response port in the same atomic scope. At compile time you will get this error: “an atomic scope may not contain or call a service or scope that contains both the send and the corresponding receive of a requestresponse operation on a 'uses' port or servicelink”.

This may seem odd at first glance, but it is due to the fact, that in order to make sure the ACID properties are respected at runtime the orchestration engine submits messages that are sent out to the messagebox, but it doesn’t release them for the messagebox to route until the atomic scope has finished. This way, if an error occurs inside the atomic scope, no messages have actually been sent, and therefore, BizTalk can guarantee a consistent state.

So basically, if the message isn’t released until AFTER the atomic scope, then there is no way you can receive the reply inside the same atomic scope. Makes sense.

SO, if you want to loop around elements in a message by calling a receive pipeline inside your orchestration, you can’t use request-response ports, as you can with other patterns. Sorry, but that is the way it is.

Conclusion:
If you want to loop around elements inside an orhestration, use a receive pipeline if possible since this is done in an atomic scope and therefore no persistence points occur. If not possible, use the pattern described here.

Thanks, Thiago for pointing out that my post needed some more details…

--
eliasen

Wednesday, 15 July 2009 19:45:03 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 

Hi all

Today I faced a very peculiar problem. I was helping a customer split a BizTalk project into two projects, because some of the schemas that were in the original project needed to be common for other projects.

So this is what i started out with:

OriginalProject

which is: Two schemas and a map between them.

And this is what I would like:

OriginalAndNewProject

So basically, the common schema has been transferred to a common project. Now, naturally, I need to reference the CommonProject from the OriginalProject and then reload the schema in my map to make it work. But this is where the weird part starts. After compiling the NewCommonProject and adding the reference, this is what showed up in the schema browser when I wanted to reload the schema in the map:

SchemaBrowser

Basically, my new project didn’t have any schemas inside it. After much troubleshooting, thinking that the issue was something with the newly compiled dll didn’t get copied to the bin folder of the OriginalProject and trying lots of stuff with that, I finally figured it out.

I just happened to notice that the file size of the NewCommonProject.dll was only 5kb which seemed to small. So I browsed the dll in the object browser and it was totally empty. Weird. Then I went and looked at the properties of the schema, and didn’t see anything unusual. So I added a new schema to the project just to see what would happen with that. This new schema showed up in the schema browser. Even weirder. But then I went and looked at the properties of the schemas again and that’s when this new property suddenly showed up:

NewProperty

I changed the build action on the schemas to be “BtsCompile” and this did the trick. Now all the schemas showed up in the schema browser.

Now, another strange side to this story is, that by now, the Build Action property has disappeared again… I haven’t quite figured out when it appears and when it does not.

BUT, if you ever run into issues where your schemas just don’t show up anywhere… this might be your issue.

Hope this helps someone.

--
eliasen

Wednesday, 15 July 2009 19:36:26 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 

Theme design by Jelle Druyts