in

wWorkflow.net

Erik Westermann, Komplett Systems test

dispatches

Erik Westermann's blog about BizTalk, Commerce Server, Integration, Writing (technical and otherwise). All content is Copyright, 2008, Erik Westermann. Permission required to duplicate. Citations appreciated.

March 2008 - Posts

  • BizTalk: Understanding Type-Safety

    This is the second in a series of excerpts from an as yet unpublished article: 

    A message in BizTalk is defined by its XML representation. Specifically, a combination of the XML document's namespace and root node name defines a message's type.

    For example, you could describe a Person using the following XML instance document:

    <pers:Person xmlns:pers ="http://example.com/sample">
        <Name>Erik</Name>
    </pers:Person>

    The document's namespace is "http://example.com/sample" and the name of the root node is Person. BizTalk represents the combination of the two like this:

    http://example.com/sample#Person

    The notation is important because you will see it when you debug routing failures, a common development-time error, and a number of other places in BizTalk.

    When BizTalk receives a Person message it publishes the message to a general location (for those of you that are interested, the general location is called the MessageBox; however, that information is not strictly necessary at this point. Interested recipients, subscribers, receive notification that a new message is waiting. BizTalk delivers the actual message to the subscriber instead of a general message, or event, that indicates that a message is available.

    A subscriber describes the message it is interested in receiving using an expression similar to this:

    http://schemas.microsoft.com/BizTalk/2003/system-properties.MessageType ==
        http://example.com/sample#Person

    While the left side of the expression (to the left side of the == operator) is new, the right side should look familiar - it is the message type of the Person message we saw earlier. Notice that the comparison is being made to a property called MessageType.

    MessageType is an attribute of all messages effectively promoting a seemingly simple XML document into a first class type. Just as in programming with a language like C#, BizTalk enforces type safety to assure that you cannot send a message to a subscriber that cannot process it, or assign incompatible messages to each other.

    You create a new message type by creating an XML Schema using the BizTalk Schema Designer in Visual Studio. You don't have to know a lot about XML or XML Schemas to be able to create a schema since BizTalk allows you to describe the schema and then handles the details of generating the type descriptions for you. This approach is called declarative programming since you focus on what you want to accomplish rather than how to accomplish it. I discussed declarative programming previously.

    Posted Mar 25 2008, 02:31 PM by Erik with 1 comment(s)
    Filed under:
  • Overcoming Writers' Block

    This does not cover techniques for how to overcome writers' block - it is a brief glimpse into a three-year journey:

    It started at the end of my last book, Learn XML In A Weekend. I enjoyed writing that book because you cannot overlook the obvious when writing for a beginner because the reader cannot discern "the obvious" from everything else. The reader seeks to understand what is obvious to you.

    That book was surprisingly difficult to write since I wanted to be pragmatic about a technical topic for readers that are not necessarily technical.

    Having gained new insights, I thought I was ready for another interesting project. I started a new project, but it fizzled out for various reasons - and I was glad about that. The writing had become much more difficult than I thought it would be. I decided to take a break since I had written a lot to that point in a relatively short period (I did other writing work that was not publically available).

    My keyboard, mouse, and pen occupied themselves with the art and practice of designing solutions for others' problems while my mind meditated on the question: why has writing become so hard and why am I not writing?

    Go for a walk. Look at things that interest you. Try puzzles. Complete someone else's sentences - maybe uncover a source of inspiration. All of the advice centered on that - inspiration - there was plenty of it around. I impaled the few words that I wrote during that time - I crossed them out...not good enough.

    "The rooftops merge with the sky when it snows. The dull light casts no shadows - colors fade into the grey background. The grey days become black nights. Headlights cut through the dark fabric, windows hang from it and the rooftops outline the dark horizon."

    Somehow, the words meandered and slowly found their way to the end of my pen. The words stood simply, honestly - a scaffold of image. And they survived in the shadow-less light.

    Accept them for what they are, allowing them to shape the image and guide you - the writer.

    Posted Mar 24 2008, 11:34 PM by Erik with no comments
    Filed under:
  • Quick Guide: Understanding BizTalk Declarative Programming

    I often demonstrate BizTalk to people that are curious about it - they could be developers, managers, even directors. Although orchestrations are great, they are not the primary means of creating a BizTalk solution. In fact, no one BizTalk technology is a primary means -- all BizTalk technologies work together in a loosely coupled way.

    In any case, when I do these demos, I try to demonstrate orchestrations last since people usually start nodding and waving their hands the moment I show an orchestration. This usually includes phrases like "So it is easy", "Just drag and drop..simple", "So this is what we pay you for?" (well...not really...I made up the last comment).

    The following is an excerpt of an article I recently wrote. The article will appear in full soon; however, this part - which describes how developers work with BizTalk is very relevant:

    Understanding BizTalk's Declarative Programming Model

    BizTalk is different in the way that you work with it. In contrast to applications you write using code, you may have seen and heard that BizTalk developers write very little, if any, code.

    BizTalk programming uses a declarative model. The declarative programming model lets you focus on what you want to accomplish rather than how to accomplish it. You are actually already familiar with declarative programming.

    When you create a Windows Forms or ASP.NET application and add a button control to a form or page, you focus on aspects like the button's position and text that appears on the button. If you review the code, you are likely to see code like this:

    button1 = new System.Windows.Forms.Button();
    button1.Size = new System.Drawing.Size(150, 45);
    button1.Location = new System.Drawing.Point(30, 15);
    button1.Text = "Click Me!";

    Notice that the code simply describes the button. The automatically generated code does not get into window handles and drawing contexts leaving the runtime to handles the details of actually drawing the button and sending click events to your event handlers.

    A BizTalk developer describes a message using an XML schema, and declares the location at which the application receives instances of the schema. The developer then describes the processing that takes place when the message arrives: the developer could transform the message, change its attributes, execute rules, and even create new types all using a declarative model.

    At runtime, the BizTalk environment handles the details of receiving messages, routing them to interested applications, and converting the developers' declarations into actions. All of this happens in a type-safe environment that makes it easier to create a technically correct solution (correct in terms of handling types and acting on them - BizTalk cannot, of course, confirm that the actions you take are correct).

    BizTalk developers can also write code within the BizTalk environment using XLang/s, a language that is modeled after C#. . Writing code in XLang/s often involves actions like message assignment, creating instances of objects, and invoking class member functions. You can use more advanced functionality using statements like call, while, and if; however, this is not strictly necessary since the orchestration designer's purpose is to make it easier to express these statements using orchestration shapes like Call Orchestration, Loop, and Decision.

    So there you have it....when someone says BizTalk is simple, refer to this excerpt and set the record straight ;)

    Posted Mar 17 2008, 06:08 PM by Erik with 2 comment(s)
    Filed under:
  • Quick method for generating Web Method message types

    Calling Web Services from your orchestrations? This easy way of getting Message types setup in your orchestration does not require that you go hunting for message types in a tiny window!

    Here is what the end result looks like:

    Create Message

    The red boxes attempt to show that the orchestration designer created Message_1 for me. Here is the procedure:

    1. Add a port to the orchestration designer surface and configure using the Web Port Type as generated when you add a Web Reference (this is the port on the right side of the image).
    2. Add a Send and Receive shape anywhere in the orchestration (Send_1 and Receive_1 in the image).
    3. Find the method you want to call on the port (RegularMethod in this example).
    4. Drag the Request handle to the Send shape.
    5. Drag the Response handle to the Receive shape.

    The result is two new Message types that correspond to the Request and Response messages - Message_1 and Message_2 in the image. Rename the message types and you're set.

    No more hunting through the tiny Message Type browser in a new Message's properties window!

    Posted Mar 14 2008, 02:47 PM by Erik with no comments
    Filed under:
  • BizTalk Mapping: Agile - to a degree

    I am working on a BizTalk project that includes a lot of mapping/transforms. Although mapping in BizTalk is great, I find the mapper limited in many ways because it is difficult, or impossible to express certain functionality.

    For example, if/then/else value mapping is very messy. For example, assume that you need to map from a value from schema A to schema B. Elements in schema A are optional (minOccurs=0) - mandatory in schema B (minOccurs=1, maxOccurs=1). As a result, elements must contain information in schema B, even if the source elements in schema A are absent or empty.

    The mapping needs to implement simple decisions: if a value in schema A exists, then map it to schema B, else map using a default value.

    Default values, in the schema or map, do not work in this case. I also tried a number of functoids including ‘IsNil' and ‘Logical Existence', combined with the ‘Value Mapping (Flattening)' functoid.

    While combining functoids works to a degree, it gets really messy when working with a lot of if/then/else mappings. Moreover I observed some inconsistent behaviour when elements in the source schema were absent.

    I am actually much more comfortable working directly with XSL than I am working with mapping tools, so I started writing my own Inline XSLT Call Template transform to use with a scripting functoid.

    The template I created worked out perfectly - it reliably generated the target type in every case. I then wanted to add it to a scripting functoid - and a new problem emerged!

    It seems that the tiny Configure Functoid Script window's editor has a limit of 30,000 characters. With a slight twist on a more popular quote, I am sure the designer thought "30k is more than enough". Famous last words.

    My transform occupies about 38,000 characters so it was incomplete when I pasted it into the window. The editor deceptively and silently dropped the remaining 8,000 characters. I found out that something was wrong the hard way when I tested my map.

    So now I am left with having to work around missing functionality in the BizTalk mapper, and now that workaround does not work because the tiny editor window accepts only 30,000 characters.

    Time for a new workaround.

    I got around this ‘design feature' by editing the BTM file using everyone's favourite editor: notepad. I found that BizTalk stores the contents of a template in a CDATA section, so I simply pasted all 38,000 characters into it, saved, compiled, and tested. It worked perfectly!

    The downside is that future developers will have to remember to edit the map outside of BizTalk.

    If you try to edit the XSLT containing more than 30,000 characters in the scripting functoid using the editor, it only allows you to delete since you are trying to work past its generous limits.

    Posted Mar 13 2008, 03:23 PM by Erik with no comments
    Filed under: ,
  • Chapter Three

     

    I have been wandering through life for the past while and have been too busy and preoccupied to post here.

    A lot has happened - here are some highlights:

    • Got a bad case of writer’s block
    • Got busy on some projects
    • Lost a lot of weight
    • Got over the writer’s block (took about two years!)
    • Started writing again :)

    I plan to write about most - perhaps all - of these and start writing technical articles too.

    There are a lot of these ‘I plan to write about’-style posts around. I think we bloggers write posts like that as a way of framing our thoughts for the next set of posts - but, somehow, the plan suddenly becomes daunting when ambition mixes with the realities of life.

    Paradoxically, the "I plan to write about"-list often becomes an excuse to avoid writing at all!

    The "I plan to write about"-list is not the end - it is a means to an end. In my case, that end is to reach out to and participate in the community. Your “end” may be different.

    This blog is actually one of my “ends” in that it took me a while to get here. I have been writing the old fashioned way: on paper and in private to develop my style (it has changed!) and get some traction for the journey. Maybe I’ll post some of those writings here.

    One thing that is ready is an article about BizTalk! The article might be published elsewhere and it is likely to appear here before then. 


    (That takes care of writing about numbers one and five on my list -- well...started them anyway!)

More Posts
Powered by Community Server (Non-Commercial Edition), by Telligent Systems