Message Debatching inside Biztalk Orchestration, with TargetNamespace.

Recently I end up in a scenario where I need to debatch a message inside the orchestration to produce multiple messages based on XPATH. There are already quite few articles about it, one good one is from Stephen Thomas hands on lab.

Only problem with this lab is, the examples are based on schemas without any TargetNamespace. In a real world situation its hard to imagine a schema without a TargetNamespace, so I spend some time to enhance the sample with TargetNamespace. I’ll highlight some of the things you need to take care when using schemas with TargetNamespace.

Download: The attached zip file contains the complete BizTalk Solution. follow the steps below to configure it:

1. Extract the sample BizTalkDebatching to C:\BTSSamples

2. Open the project in visual studio, build and deploy it. (Don’t need to create the ports, since early binding is used)

3. Open Biztalk Administration console and set the appropriate host instance for Orchestration

4. Drop the sample file (found under BizTalkDebatching\FileDrops\Sample File) into the folder FileDrops\MD_In

5. You should see 10 messages under MD_Out\After Mapping and 10 messages under  MD_Out\Before Mapping

Its quite straight forward to understand, if you have any doubts, read this article for explanation.

1. Set TargetNamespace

Make sure all your schemas has appropriate TargetNamespace, in general its very important to have a TargetNamespace, because BizTalk identifies the message based on the combination of TargetNamespace#RootElement combination.

2. We need to include namespaces in the XPath.

Any XPATH we use inside the orchestration must be fully qualified with the local name and namespace uri (TargetNamespace we set in the schemas) as shown below.

nRecordCount = System.Convert.ToInt32(xpath(Input, “count(/*[local-name()=’EnvelopeData’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’]/*[local-name()=’Data’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’])”));

3. When looping through the nodes, we need to use xpaths node-set function position() .

When we are extracting the sub message from the envelope message we’ll be extracting it based on the position inside a loop. We can make use of XPATH Node-set function position() to get to the sub message as shown below

sXPath = System.String.Format(“/*[local-name()=’EnvelopeData’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’]/*[local-name()=’Data’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’ and position()={0}]”, nLoopCount);

4. Set Schemas “ElementFormDefault” property to Qualified (default is unqualified)

When elementFormDefault is set to qualified, it implies that all the elements must be explicitly qualified, either by using a prefix or setting a {default namespace}. An unqualified setting means that only the globally declared elements must be explicitly qualified, and the locally declared elements must not be qualified. Unfortunately the default setting for elementFormDefault is unqualified.

If you don’t set the elementFormDefault value to Qualified the output will be as shown below without any values.

<?xml version=”1.0″ encoding=”utf-8″?>
<ns0:MappedData xmlns:ns0=”
http://www.digitaldeposit.net/samples/schemas”>
<Id></Id>
<Company></Company>
<FName></FName>
<LName></LName>
<OrderId></OrderId>
<RecDate></RecDate>
<ShipDate></ShipDate>
</ns0:MappedData>

Once after setting the elementFormDefault to Qualifed, you’ll get the required output.

<?xml version=”1.0″ encoding=”utf-8″?>
<ns0:MappedData xmlns:ns0=”
http://www.digitaldeposit.net/samples/schemas”>
<ns0:Id>3</ns0:Id>
<ns0:Company>City Power And Light</ns0:Company>
<ns0:FName>Greg</ns0:FName>
<ns0:LName>Chapman</ns0:LName>
<ns0:OrderId>12031-ABC-0001</ns0:OrderId>
<ns0:RecDate>5/15/2005</ns0:RecDate>
<ns0:ShipDate>5/17/2005</ns0:ShipDate>
</ns0:MappedData>

BizTalk messaging model


When I’ve started to master the BizTalk I start to build the different models for what is going on inside the BizTalk with messages. With each new iteration it was a different model.
I’ve begun with the well-known model:

 

 

 


Let’s name this model as a “Receiver-Sender model”.
This model is about the Senders and Receivers of the Messages.
Looks like the Receive Locations are the Receivers, the Send Ports are the Senders, and the Orchestrations are the Senders and the Receivers simultaneously. Right?
Wrong. All objects are the Senders and Receivers.
The Receive Locations receive the messages from the “Outer word” and send them to the Message Box.
The Send Ports receive the messages from the Message Box and send them to the “Outer word”.
The Orchestrations receive the messages from the Message Box and send them to the Message Box.
The Message Box receives the messages from the Receive Locations or the Orchestrations and sends them to the Send Ports and the Orchestrations.

 

There was a description of the Publisher-Subscriber model in the BizTalk Help. But the most of attention in the Help is to the Receiver-Sender model.

 

As I could understand, terms the Sender and Receiver confuse me.
I’ve made some changes in the model:

 

 

 

Try to move Subscriber and Publisher the terms to the first place of the model.
This model is explicitly a “Message Box centered”.
The Publishers move the messages to the Message Box.
The Subscribers move the messages from the Message Box.
All actions are across the Message Box.

 

The Publishers move the messages with defined type (namespace + root_node) to the Message Box.
The Subscribers move from the Message Box the messages with parameters defined in the Filter expression.
In this case The Receive Locations and the Send Shapes are placed in the one group the Publishers, The Send Ports and the Receive Shapes are placed in the one group the Subscribers. It is how the wrong names could complicate the things.

 

How does the Binding fit this model?

 

 

 

I’ve got something like that.
The Binding = the Implicit Subscription.
This Subscription for Binding is created under scene, when the Publishers ID is used as the Filter expression in the most cases. The link via binding is not required; it can be created by an explicit filter expression.
“Binding” the term is used for describing the direct link between an Orchestration and a Port. As I understand this term was created for simplifying the model by hiding the additional work with creating the most frequently used operation, transferring the messages from one point exactly to the second one. Binding creates the One-to-One link when the messages from one Publisher must come to the one Subscriber and only to this Subscriber. Binding make a step from “pure” Publisher-Subscriber model where the Publishers and the Subscribers do know nothing about each other and have not to know.
Binding makes the model more complicated. It simplifies this operation but not a model.
The pure model is accessible in the BizTalk by a Direct port.

 

I’ve got the more generalized model:


 

 

Here I’ve pictured Orchestration in two parts. Before that the Send and Receive Shapes were in one Orchestration, which is wrong.
I have made the sizes of the Shapes and Port/Locations equal. I had sense that the Orchestrations should not be bigger then Ports.
I’ve added “Outer World”, why not? 🙂

 

This is the Publisher-Subscriber model.

 

Conclusions are simple:


  • The Receiver-Sender model complicates the things. Try do not use Reseiver and Sender the terms for describing the message flow.
  • Binding should be on the second level of studing the BizTalk. It does not simplify the things if it is used to hide the Publisher-Subscriber model.

 

 

BizTalk 2004: ENTSSO Error 0xC0002A18

Firstly, I knew it had been a long time since I posted on my blog, as I have been snowed under with work for my current client and none of this work warranted any posts on the subject. However, I must admit I didn’t realise how long ago it was since I actually posted. Doesn’t time fly huh? I can’t say I know where this year has gone, but we all say that every year don’t we?

Anyway, I solved a relatively simple (but annoying) problem today that I hadn’t encountered before that didn’t have much information available on the internet; well, not for my particular scenario. So I thought it would be worth popping on my blog, firstly as a simple wave to say I am still alive and secondly as a reference for me in the future. You know how it is, you spend time solving problems then encounter them a few months later only to forget how you solved it. Well, I feel the blog is a good repository for this kind of information.

So, what was the issue? Well, one of our testing environments had taken a bit of a pounding recently with various non-functional tests. This is never healthy if you wish to come out at the end with the exact same environment as you started without some form of rebuild be it automated or not. While trying to deploy a custom adapter to this environment numerous errors were occurring, which led to the conclusion that there was in issue with SSO. A highly likely conclusion considering one of the non-functional tests included the restoration and movement of SSO.

During the investigation it was observed that whenever you tried to register a new adapter you would receive the following error:

SSO AUDIT
 Function: CreateApplication
 Tracking ID: e902339c-b431-40e5-a880-337bb873725b
 Client Computer: <Computer Name> (wmiprvse.exe:1232)
 Client User: <User Name>
 Application Name: {11C54F41-4C5A-4929-B828-7CD6E550BEB8}
 Error Code: 0xC0002A18, The format of the account name is not valid. Domain accounts must include the domain name. Local accounts must not include a domain or computer name.

This naturally led to an examination of all things related to SSO, in particular the SSO services. You would have thought from the error message that the service account used for SSO was incorrect. However, after too much time it transpired that the default BizTalk Host was registered using an incorrect domain group; it actually wasn’t in the domain as per the above error.

And the conclusion to this little story? Spend a little more time studying the GUIDs in the error. Only in hindsight did I think about searching out the details to find they would have guided me to the answer more quickly.

BizTalk 2004: ENTSSO Error 0xC0002A18

Firstly, I knew it had been a long time since I posted on my blog, as I have been snowed under with work for my current client and none of this work warranted any posts on the subject. However, I must admit I didn’t realise how long ago it was since I actually posted. Doesn’t time fly huh? I can’t say I know where this year has gone, but we all say that every year don’t we?

Anyway, I solved a relatively simple (but annoying) problem today that I hadn’t encountered before that didn’t have much information available on the internet; well, not for my particular scenario. So I thought it would be worth popping on my blog, firstly as a simple wave to say I am still alive and secondly as a reference for me in the future. You know how it is, you spend time solving problems then encounter them a few months later only to forget how you solved it. Well, I feel the blog is a good repository for this kind of information.

So, what was the issue? Well, one of our testing environments had taken a bit of a pounding recently with various non-functional tests. This is never healthy if you wish to come out at the end with the exact same environment as you started without some form of rebuild be it automated or not. While trying to deploy a custom adapter to this environment numerous errors were occurring, which led to the conclusion that there was in issue with SSO. A highly likely conclusion considering one of the non-functional tests included the restoration and movement of SSO.

During the investigation it was observed that whenever you tried to register a new adapter you would receive the following error:

SSO AUDIT
 Function: CreateApplication
 Tracking ID: e902339c-b431-40e5-a880-337bb873725b
 Client Computer: <Computer Name> (wmiprvse.exe:1232)
 Client User: <User Name>
 Application Name: {11C54F41-4C5A-4929-B828-7CD6E550BEB8}
 Error Code: 0xC0002A18, The format of the account name is not valid. Domain accounts must include the domain name. Local accounts must not include a domain or computer name.

This naturally led to an examination of all things related to SSO, in particular the SSO services. You would have thought from the error message that the service account used for SSO was incorrect. However, after too much time it transpired that the default BizTalk Host was registered using an incorrect domain group; it actually wasn’t in the domain as per the above error.

And the conclusion to this little story? Spend a little more time studying the GUIDs in the error. Only in hindsight did I think about searching out the details to find they would have guided me to the answer more quickly.

Sharepoint – internal/external sharepoint site reference for indexing

Usually when referencing an external website we use http://…… and
we lose all the security etc. information that comes back from our crawls. (In contrast
to the File://c:/docs/… etc etc)

A handy tip you can do is IF you know the site is a sharepoint site
you can use the SPS moniker so the indexing service uses the Sharepoint
APIs
to contact the site as opposed to the http:// protocol
handler.
(1) for SPS v2 use SPS://…..
(2) for SPS v3 use SPS3://….

Enjoy.

Sharepoint Content Dabase Restore when you have no original farm

When I was onsite recently doing a sharepoint migration to MOSS 2007 from WSS V3 –
for whatever reason all the servers (and databases) were blown away and all the client
had was one content database of their site.

(Who said client sites werent exciting)

My solution here:
(1) install and configure the farm independent of the original content database
(2) Setup the the Shared Services for the Farm
(3) Extend 1 virtual server and create a new content database.
Here’s the trick….

(4) From ‘Application Management’->’Content Databases’….add another ContentDB
(5) Now select the original ContentDB as an additional one to add.
At this point when you click ‘OK’ there should be two in the list
(I had to actually drop to the command line as this content database addition was
going to take more time than the webinterface allowed.
stsadm -o addcontentdb -databasefile:….. -databaserver:….. -url:……)
(6) From the list of two Content Databases – take the non-original ContentDB offline
and then remove it.
Viola! Worked a treak…I had to sort out a couple of things around links etc.

(I did try a few other techniques first and got a whole bunch of errors around ‘object
not in the correct state’)

Cheers,

Mick.

I discovered something interesting today…

I discovered something interesting today…

and as you well know, when people use the word “interesting” in a sentence like that its usually a euphemism.

Let me start off with some background. The Visual Studio BizTalk project system is different from the native Visual Studio project systems like C# and VB. Ok, so thats not a startling revelation, but bare with me. The BizTalk project system uses Visual Studio as a shell. Visual Studio gives the GUI front end plus build and compile functionality and thats about it. If you worked on BizTalk Server 2002 you will recall that the Mapper and Schema editor were stand alone tools at that time.

So as such, the BizTalk developer tools componentsare dependant on the functionality as supplied by the Visual Studio product. So now that i have you nodding along with melets cut to the chase. There is a limitation in the CSharp compiler that goes like this: the total size of all strings in a module must be under 0x00ffffff characters. Yeah, I can’t read hex either but my windows calculator tells me that its 16777215. Henceforth we’ll call this limitation the “16mb limitation”. Great, you say, none of the file sizes of my maps are 16mb so i don’t have a problem. Wrong! you jumped to the conclusion too fast. Lets slow down while i link up the dots.The BizTalk project system during the compilation process serialises the mapper XSLT and schema XSD code to .cs files. These .cs files then get passed to the Visual Studio compiler for the creation of the .dll assemblies.

In the example I was playing with, the Mapper project had 4 rather large maps which referenced 5 rather large schemas from a separate project. On the file system the total size of the 4 .btm files was only about 3MB’s. Each of the schemas was between 500Kb and 1MB. And of by now you should be seeing where i’m going with this. During the compilation process these 4 maps were serialised out to a total of greater than 16MBs. To use a concrete example: one of the .btm files was 1.2MB on disk, but during compilation it was serialised to 6.2mb. You have four maps like that and bingo!

So lets change gears here for a second and talk aboutwhy.

If you and I were on a .Net project together wherei was doing my developer thing and you discovered there were more than 16MBs of STRINGS in my C# project would you

a. whack me with a baseball cricket bat.
b. ask for an immediate transfer to a different project team
c. quit the company immediately because any company who hires such incompetance is going down the gurgler.

Of course this was a trick question. All of those answers are a valid course of action.

So you can see why the Visual Studio team has a limit of 16MBs of strings in a project. A.cs file is not where you do your word processing.

Ok, great, so heres the crux of the issue:

  • In a plain Visual Studio project a 16MB limitation on strings is very valid.
  • The BizTalk project system uses the Visual Studio compiler for creating the assemblies.
  • BizTalk mapper projects can have large auto generated strings made up of .xsd and .xslt code.
  • If your maps and schemas are big enough or you have enough of them in a single project the Visual Studio compiler can’t compile them because of the 16MB limitation.

You’ll know you’ve hit this issue when during compilation you get errors like this:
error CS0583: Internal Compiler Error (0xc0000005 at address 53624FD6): likely culprit is ‘CODEGEN’

The resolution is to break out the maps and or schemas into separate projects. Theres really no other way of engineering around this limitation.

Thanks for reading.

THIS BLOG DOES NOT CONDONE WORKPLACE VIOLENCE.

BizTalk Server 2006 Code Samples – Awesome!

This news is a little old now, I realised today that I forgot to post about it, but there are a whole heap of BizTalk Server Code samples that were released to MSDN back in June 06. http://msdn.microsoft.com/biztalk/downloads/samples/

Take a look at this list:

 

Publishing and Consuming Web Services with SOAP Headers
This sample demonstrates how to publish a BizTalk orchestration as a Web service with a SOAP header and how to consume the SOAP header from a Web service request message.

BAM and HAT Correlation
This sample demonstrates how to use the enhanced BAM features, and how to customize BAM and HAT integration. This sample also includes a Windows Forms application customizing BAM and HAT integration for the sample BizTalk solution.

Consuming Web Services with Array Parameters
This sample demonstrates how to consume Web services with array parameters.

Extending the BizTalk Server Administration Console
This sample demonstrates how to use the Microsoft Management Console (MMC) 2.0 Software Development Kit (SDK) to extend the functionality of the BizTalk Server Administration console with your own custom menu items, node items, new data items and views, or different views of existing data.

Viewing Failed Tracking Data
This sample uses Windows Forms to provide a simple interface to view and resubmit failed messages.

Inserting XML Nodes from Business Rules
This sample demonstrates how to insert nodes into an XML document and set their values from a business rule by using the XmlHelper class.

Using the Mass Copy Functoid
This sample demonstrates the use of the Mass Copy Functoid to map a source hierarchy to a destination hierarchy without mapping each individual element by hand.

Using Role Links
This sample demonstrates how to use role links and parties.

Split File Pipeline
This sample uses the FILE adapter to accept an input file containing multiple lines of text into a receive location.

Using Enterprise Library 2.0 with BizTalk Server
This sample demonstrates how to use Enterprise Library 2.0 with BizTalk Server.

Consuming Web Services
This sample demonstrates how to consume Web services in a messaging-only scenario, and without using the Add Web Reference option.

Console Adapter
This sample consists of a C# console application that instantiates and hosts an instance of the receive adapter. The adapter is a Visual Studio 2005 class library that invokes the BizTalk Server 2006 APIs.

Delivery Notification
This sample demonstrates how acknowledgments work and how to use delivery notification.

Using Long-Running Transactions in Orchestrations
This sample demonstrates how to use long-running transactions in orchestrations.

Using the Looping Functoid
This sample transforms catalog data from one format to another by using the Looping functoid.

Mapping to a Repeating Structure
This sample demonstrates how to map multiple recurring records in an inbound message to their corresponding records in the outbound message in the BizTalk Mapper.

Parallel Convoy
This sample demonstrates how to design the parallel convoy pattern in BizTalk Orchestration Designer.

Policy Chaining
This sample demonstrates how to invoke a policy from another policy by calling the Execute method of the Policy class exposed directly by the Microsoft.RuleEngine assembly.

Recoverable Interchange Processing Using Pipelines
This sample demonstrates how to implement recoverable interchange processing.

Using the Table Looping Functoid
This sample demonstrates the use of the Table Looping functoid in gated and non-gated configurations.

Using the Value Mapping and Value Mapping (Flattening) Functoids
This sample demonstrates the use of the Value Mapping and Value Mapping (Flattening) functoids to transform data between different message formats.

Direct Binding to an Orchestration
This sample processes fictitious loan requests using orchestrations with ports that are directly bound to another orchestration

Direct Binding to the MessageBox Database in Orchestrations
This sample processes fictitious loan requests using orchestrations with ports that are directly bound to the MessageBox database.

Using a Custom .NET Type for a Message in Orchestrations
This sample processes fictitious customer satisfaction survey responses from clients who spend time at different resort properties. Clients assign an overall satisfaction rating and can optionally enter a contact address and request a personal response. A request for a personal response generates a new message that is forwarded to a customer service application for tracking and follow-up.

Writing Orchestration Information as XML Using the ExplorerOM API
The sample performs two tasks. First, it writes configuration information for all orchestrations defined for a BizTalk server into a user-specified XML file. It then optionally transforms the XML data into a simple HTML report. This is accomplished through a console application.

Correlating Messages with Orchestration Instances
This sample receives a purchase order (PO) message from a fictitious customer and processes the purchase order message using correlation.

SSO as Configuration Store
This sample provides an implementation of a sample class and a walkthrough that demonstrates how to use the SSO administrative utility and the SSOApplicationConfig command-line tool.

Atomic Transactions with COM+ Serviced Components in Orchestrations
This sample demonstrates how atomic transactions work in orchestrations.

Exception Handling in Orchestrations
This sample demonstrates how to handle exceptions in an orchestration.

Implementing Scatter and Gather Pattern
This sample demonstrates how to implement the Scatter and Gather pattern using BizTalk Orchestration Designer.

Using the SQL Adapter with Atomic Transactions in Orchestrations
This sample shows how to use the SQL adapter with atomic transactions to keep databases consistent.