Blog Home  Home |  Breeze Home RSS 2.0 Atom 1.0 CDF  
Scott's Breeze Blog - RFID, BizTalk - BizTalk General
...and everything in between
 
 Wednesday, November 12, 2008

Putting together BizTalk integration solutions can be complex and tricky at times. Debugging them is an art in itself. While onsite recently, I found myself (on more than one occasion) having *words* with BizTalk.

One example that tested our relationship (BizTalk and I) was an orchestration decision shape that appeared to be misbehaving. I had three branches in the decision shape, each branch testing the existence of a node in the message being processed using the xpath() function. For Example:

xpath(msgRequest, "string(count(/*[local-name()='root']/*[local-name()='parent']/*[local-name()='child' and code='some value']))") == "0"

Tip: use Dan Sharp's Xml Viewer to retrieve the correct xpath to use in these statements. BizTalk schemas will give you them to, but Dan's tool has some nice features thrown into the bargain smile_wink

One branch rule tested for a zero node count, another for exactly one, and the Else rule branch to handle multiple occurrences of the node. During testing and debugging we found the else branch was always being used despite the messages satisfying one of the other rule conditions (over different tests). Repeated checks, breakpoints, and logging soaked up 20 minutes or more and had me demanding satisfaction by challenging BizTalk to a duel with pistols at dawn. smile_angry

It was then, a bright beam of light breached the false ceiling above me and shone down in all is splendour. No, this was not a helping hand from god, but rather from a colleague working with me. Picking up on my frustrations, he calmly stood, moved over to me, and placing a soothing hand on my shoulder, utters two words that have changed my life...Kane Theory. I eagerly implemented a quick change (as guided by Kane Theory teachings) and my problem was solved! More cases arose during the project and each of them resolved with ease using this mystic and elegant theory.

Ok. That's a bit dramatic, but I am considering a professional self-help book exploring the practical uses of Kane Theory and wanted to get some practice in.

So what is Kane Theory?

Although only a novice in its teachings, I am fortunate to receive guidance from the enlighten one himself. Kane Adams (his real name used here to protect reveal his identity)  explains it in terms of Yin & Yang, Karma, and the Force. Reflecting on this I can best describe it as a derivative of keep it simple stupid (KISS).

In the example above, we declared an orchestration variable (System.String) to store the result of the xpath function in an Expression shape before entering the Decision shape. We then used the variable in the rule expression for the comparison. Eg:

strNodeCount == "0"

By powers understood only to the enlighten one, this worked a treat and we could all break for a quick cup of the worst coffee ever brewed. (Sceptics might argue that it has to do with the way the XLANG engine performs explicit type conversions during the comparison operation...but they would say that wouldn't they!)

As for the enlighten one himself:

Some say he is a direct descent of John Adams, author of the mystical theory of political architecture and founding father of the new Empire (there's the link to the Force we needed).
Some say, he meditates to the haunting chants of mid-level public servants.
We know him as The Stig!

Author of the enlighted

11/12/2008 10:47:01 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [1]   BizTalk General | Humour  |  Trackback
 Monday, September 22, 2008

Had a strange error appear last week when using the WCF LOB Adapter for Oracle and spent an hour of my life I will never get back. When attempting to connect to an Oracle DB we kept getting the following error:

ORA-12154: TNS:could not resolve the connect identifier specified

This occurred when we:

  1. Tried to generate metadata in our BizTalk project using the Add Generated Items wizard.
  2. Tried to generate metadata in a Class Library project using the Add Adapter Service Reference wizard.
  3. Connect to an Oracle DB using the Oracle Explorer.

We had all the latest versions/patches of the Oracle client and WCF LOB Adapter (Oh, yeah. Thanks Oracle for packaging patches in easy to consume 1GB downloads...love your work!!)

We could however, connect to Oracle using the Oracle SQL Developer Tool. So we knew something was happening (or not happening inside of VS).

It turns out the issue relates to the install directory of VS2005. In our case it was

C:\Program Files (x86)\...

This triggers an *undocumented feature* in the Oracle Data Provider for .Net (ODP.NET) so that applications with a parenthesis in their (exe) path fail to connect to the server.

The solution was to uninstall VS2005 and reinstall using a different install directory *one that did not have (x86) in it*.

smile_confused ... I know, I did not want to believe it either, but if you want to save yourself time and hair try this solution first.

9/22/2008 11:31:09 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0]   BizTalk General | WCF LOB Adapters  |  Trackback
 Friday, June 06, 2008

Recently I implemented a BizTalk web services interface that required the need to support SoapFault messages. I quickly fell into a common trap and received a compiler error:

error X2162: must receive before sending a fault message on an implemented port

(see Scott Colestock's post that nicely outlines his experience with the same issue)

As Scott describes, the solution involved using the succeeded() function to first test if a transaction scope had succeeded or not in order to send out my soap-fault correctly. I vaguely recalled this function but never used it in anger before. After having spent a hour or so I will never get back, I made a note-to-self to seek out and reacquaint myself with the other operators and functions available to use in expression shapes within an orchestration.

Here is the full list taken from the online documentation:

Operator

Description

Example

checked()

raise error on arithmetic overflow

checked(x = y * 1000)

unchecked()

ignore arithmetic overflow

unchecked(x = y * 1000)

new

create an instance of a class

myObject = new MyClass;

typeof

Type retrieval

myMapType = typeof(myMap)

succeeded()

test for successful completion of transactional scope or orchestration

succeeded(<transaction ID for child transaction of current scope or service>)

exists

test for the existence of a message context property

BTS.RetryCount exists Message_In

+

unary plus

+(int x)

-

unary minus

-(int x)

!

logical negation

!myBool

~

bitwise complement

x = ~y

()

cast

(bool) myInt

*

times

Weight = MyMsg.numOrders * 20

/

divided by

x / y

+

plus

x + y

-

minus

x - y

<<

shift left

x << 2

>>

shift right

x >> 2

<

less than

If (MyMsg.numOrders < 10)...

>

greater than

If (MyMsg.numOrders > 10)...

<=

less than or equal to

If (MyMsg.numOrders <= 10)...

>=

greater than or equal to

If (MyMsg.numOrders >= 10)...

==

equal to

If (MyMsg.numOrders == 10)...

!=

not equal to

If (MyMsg.numOrders != 10)...

&

and

If (myByte & 255)...

^

exclusive or

If (myByte ^ 1)...

|

or

If (myByte | 1)...

&&

conditional and

If (MyMsg.numOrders > 10) && (MyMsg.numOrders < 100)

||

conditional or

If (MyMsg.numOrders < 10) || (MyMsg.numOrders > 100)

//

commenting

//This is the comment

Since then, this little exercise has helped in a few occasions, particularly the need for the exists function when working with optional property schema fields.

I knew I should of read the manufacturers instructions smile_wink

6/6/2008 12:42:47 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0]   BizTalk General  |  Trackback
 Tuesday, May 27, 2008

Today I was working on a BizTalk solution to intercept, transform, and relay emails sent from a LOB system. BizTalk polled a POP3 mailbox and my orchestration replaced the original plain/text email body with some fancy, template driven HTML content and sent it out a dynamic SMTP send port. Only the email body was to be modified, the rest of the email message was to replicate the original email message, including any attachments (that may or may not be present).

To aid in testing I wrote a simple .Net email client. (I got tired of composing a new email in Outlook every time I wanted to test the solution)

Breeze Simple Email Client

The solution worked well (and perhaps I may post about the details sometime later) accept for the fact the outbound message had lost the attachment filenames.

inbound showing attachment

outbound showing attachment

Note: The attachment on the outbound message has a filename of ATT00241.DAT smile_confused

A helper class in my orchestration inspected the inbound message for attachments and added them to the new outbound message. Each message part (attachment) was assigned the MIME message part context properties of the same inbound message part. What I found was the MIME.FileName property was not being populated by the MIME decoder.

The MIME decoder in the POP3 adapter (when configured to apply MIME decoding) populates the following message part context properties when a MIME encoded message is received:

MIME/SMIME Property Schema and Properties

I checked the message source of the email I was sending (via my DIY email client) to check the MIME headers were present.

incorrect message source

Appears OK right?...

content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64

Wrong smile_embaressed

It turns out the MIME decoder is looking for the content-disposition header values

content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64
content-disposition: attachment; filename=SampleAttachment.zip

So some quick changes to the Breeze Simple Email Client ...

attach.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment
attach.ContentDisposition.FileName = Path.GetFileName(attachmentFileName)

...and we were back to cooking with gas.

correct message source

and now attachments on our outbound message retain their original filename...noysh!

outbound showing correct attachment

And BTW, not all commercial email clients populate these MIME headers correctly either (or so a friend of a friend who's aunt once knew someone that was talking to a girlfriend at the supermarket said). Check out the message source of items in your inbox. You might be surprised. smile_regular

Happy spamming er...umm...BizTalking

5/27/2008 12:10:09 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [2]   BizTalk General  |  Trackback
Copyright © 2008 Breeze Training. All rights reserved.