Category: BizTalk

  • InfoPath Rules Grouping Behavior (And New BizTalk Posters)

    A buddy at work is designing an InfoPath form and was befuddled by some awkward behavior in the way InfoPath executes its rule conditions.

    So let’s say that you want to execute the following comparison:  “If the sum of the order is greater than $500, and, the customer is from either CA or FL, then set a 10% discount rate.”  In essence you have a “A & (B | C)” situation.  So my pal had a rule that fired which checked these conditions.  On the first pass, his rule conditions looked like this:

    Makes sense, BUT, where does InfoPath put the parentheses?  Not where we first thought.  The way this rule is written, InfoPath executes it as “(A & B) | C“.  That is, if I just enter “FL” into my textbox, the rule passes because as long as the state equals “FL”, the first condition doesn’t matter.   The “and’s” take precedence over the “or’s”.

    So, how do I get the conditions to line up as I really want?  You actually have to break apart the condition to look like “(A & B) | (A & C)” such as:

    This way, the two fields on both sides of the “and’s” are grouped together and split by the “or.”

    You also max out on the number of rule conditions at 5, so if you have a rule with a large set of conditions, you’ll need to split it up into multiple rules.  I still like InfoPath, but man, I’ve been getting punched in the face by little quirks for the past few weeks.

    As a complete non-sequitur, I noticed that the BizTalk team just released yet another poster (this one on the BizTalk Adapter Pack and LOB SDK).  Besides expecting 14 different blogs on the MSDN site to do nothing but cut and paste the announcement,  this also means that I shouldn’t make fun of the team’s poster-producing prowess ever again.   I’m still holding out hope for the “Women of BizTalk Server” poster.  Fingers crossed.

    Technorati Tags: , BizTalk

  • Sending Flat File Payload in a SOAP Message

    So we have a project where pieces of data are sent to an external party.  This party exposes a “service” to accept the data.  However, the “service” takes in a few pieces of metadata, and then accepts a comma-delimited string of values as the actual payload.  Ugh.  Ignoring the questionable design, how would I take what was originally XML content, turn it into a delimited structure, and then jam it into the outbound SOAP message?  Let’s see how we’d do that in BizTalk Server.  What I’ll show here is how to call the flat file assembler pipeline from an orchestration, and use a custom component to yank out the flat file content and put it into an XML element.

    First, I need some schemas.  I’ll start with the XML schema representing my company’s data.  This example schema is fairly simple and holds some basic employee information.

    Next, I have to create the flat file schema that puts the data in the delimited format required by the vendor.  I started with a instance file, and used the Flat File Wizard to generate the XSD schema.

    Now I need the schema representing the message that I’m sending to the vendor.  It has a timestamp value, and then a string which holds the comma-delimited payload.

    After the schemas are created, I need a map.  Specifically, I created a map from my company’s XML format to the delimited format.

    A custom pipeline is needed to convert a message to a flat file output, so I built a send pipeline that utilizes the flat file assembler component.

    Great.  Now, before I build the orchestration, I need a helper component which can extract the candy center from my flat file message.  So, I have a C# class library project with a class called FlatFileExtractor.  This object has a single static operation called ExtractText.   This project references the Microsoft.XLANGs.BaseTypes.dll found in the BizTalk installation directory.  The code of the operation looks like this …

    [Serializable] public class FlatFileExtrator { public static string ExtractText(XLANGMessage inputMsg) { string result; //pull out message payload as stream StreamReader sr = new StreamReader( (Stream)inputMsg[0].RetrieveAs(typeof(Stream))); //load stream contents into string result = sr.ReadToEnd(); return result; } }

    So, if I pass in a message object from my orchestration, it should return me the guts of that message as a string.

    Now I can create my orchestration.  First off, I need to receive and transform the initial XML message.  Let’s get it into the flat file schema format.

    Next I get into the whole “call pipeline from orchestration” magic.  Within an atomic scope, I declare a variable of type Microsoft.XLANGs.Pipeline. SendPipelineInputMessages (make sure you reference the Microsoft.XLANGs.Pipeline.dll first).  Within that scope, I have a “message construct” shape where I’m constructing a new message of the flat file schema type.

    Within the assignment shape, I have the following code …

    //instantiate message as null WorkforceFFResult_Out = null; //add map result message to input array SendInputMsgs.Add(WorkforceFF_Output); //call pipeline Microsoft.XLANGs.Pipeline.XLANGPipelineManager. ExecuteSendPipeline(typeof(Demo.Snd_Workforce_FF), SendInputMsgs, WorkforceFFResult_Out);

    After this executes, the “WorkforceFFResult_Out” message is holding the contents of the raw delimited flat file that went through the pipeline processing.

    You can probably guess what’s next.  Now I have to create the vendor-specific message.  First, I use a map to simply build up the message instance.  Then, I set the distinguished “payload” value using my helper class.

    The “assignment” looks like this …

    VendorTransfer_Output.Payload = Demo.Helper.FlatFileExtrator.ExtractText( WorkforceFFResult_Out);

    Finally, I send the message out.  What does the resulting message look like?  Something like this …

    So, hopefully you don’t run across this exact situation ever, but, if you do need to convert a message to a flat file and extract the text for additional processing, this pattern may help you out.

    Technorati Tags:

  • New BizTalk Performance, WCF Whitepapers

    I was looking for a particular download today on the Microsoft site, and came across a couple of new whitepapers.  Check out the Microsoft BizTalk Server Performance Optimization Guide which 220+ pages of performance factors, analytic tools, planning/preparing/executing a performance assessment, identifying bottlenecks, how to test, and optimizing operating system / network / database  level settings.

    Also check out the new whitepaper on BizTalk 2006 R2 integration with WCF.  This is a different paper than Aaron’s WCF adapter paper from last year.

    And not sure if you’ve seen this, but the BizTalk support engineers are blogging now and chat about orchestration performance and other topics.  The recent post covers singletons, which is of recent interest to folks I know.

    Technorati Tags: , WCF

  • New WCF Management Pack for SOA Software

    I was on a conference call with those characters from SOA Software and they were demonstrating their BizTalk Management Pack.  They also spent a lot of time covering their in-development WCF binding.

    Moving forward, SOA Software is releasing Microsoft-friendly agents for …

    • IIS 6.0 (SOAP/HTTP)
    • WCF (any transport)
    • BizTalk (any transport)
    • BizTalk-WCF (any transport)

    All of these (except the BizTalk agent) support policy enforcement.  That is, the BizTalk agent only does message recording and monitoring whereas the other agents support the full suite of SOA Software policies (e.g. security, XSLT, etc).

    So what is the difference between the BizTalk agent, and the BizTalk-WCF agent?  The relationship can be represented as such:

    The BizTalk-only agent is really a pipeline component which captures things from inside the BizTalk bus.  This means that it will work with ANY inbound our outbound adapter.  Nice.  The SOA Software WCF binding is at the WCF adapter layer, and allows for full policy enforcement at the adapter layer.  However, this is ONLY for the BizTalk WCF adapters, not the other adapters.

    So if I had a WCF endpoint that I wanted to play with SOA Software, I could first attach the out-of-the-box SOA Software pipelines to the receive location.

    Next, in the WCF-CustomIsolated adapter configuration, I can specify the new soaBinding type.

    I don’t HAVE to do the pipeline AND the WCF binding if I have a WCF endpoint, but, if I want to capture the data from multiple perspectives, I can.  For that binding, there are a few properties that matter.  Mostly importantly, note that I do NOT have to specify which policy to apply.  The appropriate policy details are recovered at runtime, so making changes to the policy requires no changes to this configuration.

    From within the SOA Software management interface, I can review my BizTalk endpoints (interpreted as operations on a WSDL that represents the BizTalk “application”).

    Notice that this is a managed BizTalk receive location.   If I sent something through this managed receive location (with a policy set to record and monitor the traffic) I could see a real-time chart of activity, and, see the message payload.

    Notice that I see all the context values, AND, the payload in a CDATA block.  This supports BizTalk flat file scenarios.

    As for the WCF binding, you would install the SOA WCF binding on the client machine, and it becomes available to developers who want to call the SOA-managed WCF service.  The binding looks up the policy details at runtime, again shielding the developer from too much hard coding of information.

    So what’s cool here?  I like that the BizTalk agent works for ALL BizTalk adapters.  You can create a Service Level Agreement (SLA) policy where more than 10 faults to an Oracle adapter send port results in an email to a system owner.  Or if traffic to a particular FILE receive location goes above a certain level (per day), then raise an issue.  From the WCF side, it’s very nice that all WCF transports are supported for service management and that service policy information is dynamically identified at runtime versus embedded in configuration details.

    If you’re a BizTalk shop, and you have yet to go nuts with SOAP and services, you can still get some serious value from using the BizTalk agent from SOA Software.  If you’ve fully embraced services, and are already on the WCF bandwagon, the upcoming WCF binding from SOA Software provides a vital way to apply service lifecycle and management to your environment.

    Technorati Tags: , , WCF

  • All Source Code Posted for BizTalk + WCF Articles

    I just finished zipping up all the source code for my recent set of articles over at TopXML.com.  Specifically, I just added the source code for the set of articles on publishing WCF services out of BizTalk (with security, transactions, attachments) and the source code for all the BizTalk Adapter Pack demonstrations that utilized the Oracle adapter.  I make no promises that the code is attractive, contains best practices, or avoids the use of obscenities in the comments.

     

    Series Summary
     BizTalk and WCF: Part I, Operation Patterns Get the source code!
     BizTalk and WCF: Part II, Security Patterns
     BizTalk and WCF: Part III, Transaction Patterns
     BizTalk and WCF: Part IV, Attachment Patterns
     BizTalk and WCF: Part V, Publishing Operations Patterns Get the source code!
    BizTalk and WCF: Part VI, Publishing Advanced Service Patterns
    BizTalk and WCF: Part VII, About the BizTalk Adapter Pack Get the source code!
    BizTalk and WCF: Part VIII, BizTalk Adapter Pack Service Model Patterns
    BizTalk and WCF: Part IX, BizTalk Adapter Pack BizTalk Patterns

     

    Technorati Tags: ,

  • BizTalk "Message Aggregation For Email" Pattern

    One of our BizTalk developers had a requirement to collect related messages and send a single email summary with details about those messages. I built the example below to help her out.

    In this scenario, a series of independent, but related, messages are sent to BizTalk. Each of these messages will have a “batch ID” which connects them as well as a “batch count” value which identifies the total number of messages in the batch. As you might expect, I’ll need a convoy to collect these messages. The interesting part was how to build up the email data which summarized the results of the processing for a given batch.

    First, I have a schema that represents an individual message.

    As you can see, I have details about the batch, and then a record containing details about the document that was processed through BizTalk. These fields are mostly populated by the system called by BizTalk earlier in the process and those new values need to be reported back to the initiator of the submission.

    The next schema represents the email content being sent back to the initiator. There is a summarization of the batch of records they submitted, and then one section where successfully processed documents are recorded, and a section where failed documents are recorded.

    Next, we need a convoy orchestration that processes all messages for a given batch. The first receive shape initializes a correlation set on “batch ID” (from a separate property schema) and then initializes the loop variables. This loop will run until all the number of messages received is equal to the “batch count” in the message.

    The meat of this orchestration is the part that builds up the email message. I have a helper class that accepts data from each batch message, and stores it in a member variable until I’m ready to return the completed, aggregate message. Now, I could have chosen to build some sort of custom type object, and when the loop was complete, turn that object into the XML representation of my email schema. But, I’d rather cut out that middle man. So, I passed my “BatchSummary” schema (above) through the .NET Framework xsd.exe tool to get a type object that directly mapped to the schema. That type is used as a member variable of my helper class.

    You’ll notice that I also created a few lists to hold the success and failure item types. The “BatchSummary” object takes in an array of success and failure items, but during the running of the convoy, I have no idea how many success or failure items I have, and thus couldn’t properly initialize an array of the necessary size. So, by creating a list, and simply adding to it along the way, I can postpone array creation until later.

    Within this class I have operations to add message data elements to the appropriate “success” or “failure” list object, and then finally, the convoy orchestration should call the operation below to get a “completed” batch summary object.

    The next part is fun. I created an orchestration message for the batch email message, but, instead of choosing the XSD file for the “Message Type”, I chose the object generated by the xsd.exe tool.

    This .NET object has all the necessary metadata to automagically serialize into an XML message on the way out of the orchestration. At the end of the orchestration loop, I have a “message assignment” shape where I create the orchestration message by calling the appropriate operation on my helper class.

    Because I want to take this XML payload and turn it into an HTML email, I need to massage the data on the way out. For this scenario, I used the XslTranformComponent sample from the BizTalk SDK (C:\Program Files\ Microsoft BizTalk Server 2006\ SDK\ Samples\ Pipelines\ XslTransformComponent). After building this pipeline component and GAC-ing it, I created a new send pipeline and dropped this component there. Finally, I wrote an XSLT stylesheet which took the XML and prettied it up. Now, when I drop three files (all with the same “batch ID”) into BizTalk, I get the following email:

    Nice! So, with fairly few moving parts, I collected a bunch of related messages, built up a new composite message on the fly, and then send a .NET object-type orchestration message out, which had an XSLT transform applied before being emailed to the target recipient.

    Technorati Tags:

  • New BizTalkHotRod Issue Out; BizTalk Bloggers to Check Out

    The latest issue of the BizTalk HotRod magazine is out.  Some of the topics you’ll find are:

    • Detailed look at using the ESB Guidance Exception Management framework
    • Exposing BizTalk BRE rules via WCF services
    • Look at parallel convoys
    • Peek at the BizTalk WCF adapters
    • Taking control of XSLT in BizTalk solutions
    • Hosting WF in BizTalk

    And much more.  As usual, a well done issue.

    Skimming through this issue got me thinking about where I get my BizTalk information, and reminded me to update my RSS reader so that I regularly read some of the “newer guys” who cover BizTalk topics.  Some of the original BizTalk giants (like Steven, Tomas, Charles, Scott, Jon, Lee, etc) have (naturally) shifted some of their attention to other technologies, so it’s important to keep an eye out for folks who are taking a fresh look at BizTalk things.

    Some of the blogs I read on occasion (but need to actually subscribe to) include:

    I need a show of hands of who still has Scott Woodgate on their BizTalk blogroll.  Seriously people, it’s time to let go. 

    Technorati Tags:

  • BizTalk Orchestration Throttling Pattern

    I’m currently architecting a project where one of the requirements is to limit the number of concurrent calls to a web service. I’d covered a similar topic in a previous post, and outlined two ways one could try and configure this behavior.

    First, you could limit the number of simultaneous connections for the SOAP adapter by setting the “maxconnections” setting in the btsntsvc.exe.config file. The downside to this mechanism is that if you have many messages, and the service takes a while to process, you could timeouts.

    The second choice is to turn on ordered delivery at the send port. This eliminates the timeout issue, but, really slows processing. In our case, the downstream web service (a FirstDoc web service that uploads documents to Documentum) is fairly CPU intensive, and may take upwards of 200 seconds to run (which is why I also asked the developer to consider an asynchronous callback pattern), so we need a few calls happening at once, but not so many that the box collapses.

    So, Scott Colestock recommended I take a look at the last issue of the BizTalk HotRod magazine and review the orchestration throttling pattern that he had expalined there. Unlike the two options mentioned above, this DOES requirement development, but, it also provides fairly tight control over the number of concurrent orchestrations. Since Scott’s article didn’t have code attached, I figured I’d rebuild the project to help our developer out, and, learn something myself.

    The first step was to define my two BizTalk message schemas. My first is the schema that holds the data used by the FirstDoc web service. It contains a file path which the web service uses to stream the document from disk into Documentum. I didn’t want BizTalk to actually be routing 50MB documents, just the metadata. The second schema is a simple acknowledgement schema that will be used to complete an individual processing instance. Also, I need a property schema that holds a unique correlation ID, and the instance ID of the target convoy. Both properties are set to MessageContextPropertyBase since the values themselves don’t come from the message payload but rather, the context.

    The second step was to build a helper component which will dictate which throttled instance will be called. Basically, this pattern uses convoy orchestrations. The key is though, that you have multiple convoys running, vs. a true singleton that processes ALL messages. The “correlation” used for each convoy is an instance ID that corresponds to a number in the numerical range of running orchestrations allowed. For instance, if I allowed 10 orchestrations to run at once, I’d have 10 convoy orchestrations, each one initializing (and following) an “InstanceID” between 1-10. Each of my calling orchestrations acquire a number between 1-10, and then target that particular correlation. Make sense? So I may have 500 messages come in at once, and 500 base orchestrations spin up, but each one of those target a specific throttled (convoy) orchestration.

    So my helper component is responsible for doling out an instance ID to the caller. The code looks like this:

    [Serializable] public static class RoundRobinHelper { //member variable holding current selection private static int roundRobinSelection = 0; private static object sync = new object(); /// /// Thread-safe retrieval of which /// orchestration instance to target /// /// public static int GetNext() { const int maxInstances = 3; lock (sync) { //increment counter roundRobinSelection++; //if we’ve reached the limit, reset if (roundRobinSelection == maxInstances) { roundRobinSelection = 0; } } return roundRobinSelection; } }

    Notice that because it’s a static class, and it has a member variable, we have to be very careful to build this in a thread safe manner. This will be called by many orchestrations running on many threads.

    Once this component was built and GAC-ed, I could build my orchestration. The first orchestration is the convoy. The first receive shape (which is direct bound to the MessageBox) initializes the “instance ID” correlation set. Then I have a loop which will run continuously. Inside that loop, I have a placeholder for the logic that actually calls Documentum, and waits for the response. Next I build the “acknowledgement message”, making sure to set the “Correlation ID” context property so that this acknowledgement reaches the orchestration that called it. I then send that message back out through a direct bound send port. Finally, I have a receive shape which follows the “Instance ID” correlation set (thus defining this orchestration as a convoy).

    Next, we have the orchestration that spins up for EVERY inbound message. First, it receives a message from a port bound to a file receive location. Next, within an Expression shape, I call out to my “round robin” helper component which gives me the next instance ID in the sequence.

    ThrottledInstanceId = BizTalkPattern.OrchHelper.RoundRobinHelper.GetNext();

    I then make sure to create a new message with both the “Correlation ID” and “Instance ID” context properties set.

    //create message copy Metadata_Output = Metadata_Input; //set convoy instance ID Metadata_Output(BizTalkPattern.BizTalkBits.InstanceId) = ThrottledInstanceId.ToString(); //set unique ID using orchestration instance identifier Metadata_Output(BizTalkPattern.BizTalkBits.CorrelationID) = BizTalkPattern.BizTalkBits.ProcessAllMetadataFiles (Microsoft.XLANGs.BaseTypes.InstanceId);

    Finally, I send this message out (via direct bound send port) and wait for the acknowledgement back.

    So what I have now is a very (basic) load balancing solution where many inbound messages flow through a narrowed pipe to the destination. The round robin helper component keeps things relatively evenly split between the convoy orchestrations, and I’m not stuck using a singleton that grinds all parallel processing to a halt.  Running a few messages through this solution yields the following trace …

    If I look in the BizTalk Administration Console, I now have three orchestrations running at all times, since I set up a maximum of three convoys.  Neat.  Thanks to Scott for identifying this pattern.

    Any other patterns for this sort of thing that people like?

    Technorati Tags:

  • Material from San Diego .NET User Group Presentation

    Earlier this week, I grabbed a couple new CDs, hopped in the car, and drove down to San Diego to present at the .NET User Group’s Connected Systems meeting.  The topic was the BizTalk Adapter Pack and I outlined what the BAP is, what the core use cases are, and demonstrated how to build a solution using it.

    My presentation is here.  I called out a few resources for folks looking to learn about the BizTalk Adapter Pack.  They include:

    I’ve been accepted into the Microsoft TAP for the Adapter Pack Office Developers Program, so hopefully I’ll be able to demonstrate how to use the BAP within Office applications.

    Technorati Tags: ,

  • Article Series on BizTalk and WCF: Part IX, BizTalk Adapter Pack BizTalk Patterns

    UPDATE: I have since moved these articles to my own blog and they can be found here.

    Whew.  My 9th and final article for TopXML.com on integrating BizTalk Server and WCF is now published.  This one looks at the BizTalk Adapter Pack and how to consume the Oracle adapter from inside BizTalk Server.  I demonstrated how to insert multiple records at once, call stored procedures, build a database polling solution, and how to call the Adapter Pack from an orchestration using code.

    20,500+ words and 178 screenshots later, I definitely learned a lot about WCF (and Oracle) by writing this series of articles.  I found the security and attachment topics to be challenging, the transaction topics to be quite interesting, and the BizTalk Adapter Pack to be quite compelling.  The WCF integration in BizTalk Server 2006 R2, while not as rich as it could be, is actually pretty darn well built and thought out.

    When I started out on this series, I figured that writing about BizTalk/WCF and then the BizTalk Adapter Pack would be somewhat “niche” for the majority of developers, but, hopefully this helps people down the line as they begin to really investigate and evaluate these technologies together.

    Series Summary
     BizTalk and WCF: Part I, Operation Patterns Get the source code!
     BizTalk and WCF: Part II, Security Patterns
     BizTalk and WCF: Part III, Transaction Patterns
     BizTalk and WCF: Part IV, Attachment Patterns
     BizTalk and WCF: Part V, Publishing Operations Patterns Get the source code!
    BizTalk and WCF: Part VI, Publishing Advanced Service Patterns
    BizTalk and WCF: Part VII, About the BizTalk Adapter Pack Get the source code!
    BizTalk and WCF: Part VIII, BizTalk Adapter Pack Service Model Patterns
    BizTalk and WCF: Part IX, BizTalk Adapter Pack BizTalk Patterns

     

    Technorati Tags: ,