SharePoint Integration without Cheating in BizTalk 2013

This post is the fourth in a weekly series intended to briefly spotlight those things that you need to know about new features in BizTalk Server 2013.

In the Support for new Adapters section of the new features list for BizTalk Server 2013, you will find a very brief note without much explanation about the SharePoint adapter in BizTalk Server 2013:

BizTalk Server 2013 also provides updates to SharePoint adapter that gives users the option of choosing between using the client-side or server-side object model for connecting to a SharePoint server.

While this is nicely succinct1 and technically accurate, it really does not do a great job at explaining the implications. In order to uncover that, we actually have to look to the past – all the way to the year 2010.

A Brief History of Recent Time

In BizTalk Server 2010 (or more specifically, all versions including the WSS adapter), when we wanted to allow a BizTalk process to interface with SharePoint, we had to install a special web service that ran on the SharePoint server. This web service was installed by BizTalk and interacted with the server-side object model of SharePoint to provide access to data within SharePoint document libraries.

In a sense, to do a SharePoint integration, we had to cheat. We had to modify the target system to help adjust it to BizTalk – as opposed to leaving that system alone and integrating with it in a purely native way. Now one can easily argue that this is a slight exaggeration (since BizTalk did use an established interface in the form of the server-side object model), however it was still fairly inconvenient to have to install that adapter web service in each SharePoint environment with which I wanted to enable integration.

At around the same time that BizTalk Server 2010 was released, SharePoint 2010 was also released, and sported a brand new method (actually a few brand new methods) for accessing data – specifically the client-side object model. The client-side object model operates through a special service that SharePoint already exposes itself. This service is able to process bulk requests and the interaction with this service can be accomplished using proxy classes implemented in .NET, Silverlight, and JavaScript code – all of which more or less conform to the same naming and patterns for use.

With this client-side object model exposed starting in SharePoint 2010, the BizTalk team was able to take full advantage of it in the 2013 release of BizTalk Server. As a result, we now find this delightful option within the adapter configuration:

csom

Also, without having to install anything specific on the SharePoint server to support communication with BizTalk Server 2013, it opens up the door for the updated WSS adapter to access SharePoint Online with only a few minor tweaks for a different authentication method – and indeed the team made those investments as well:

sponline

The Little Things

Sometimes, its the seemingly little things that will make all of the difference. If you’re trying to tackle a SharePoint integration, and you’re on BizTalk Server 2010, consider the move up. Not only will it make you feel good to do things in a pure way that will satisfy those that hold tightly to the enterprise integration dogma, but it will also be less of a headache at installation time.

If you would like to learn more about the enhancements to the SharePoint Adapter, check out one of our upcoming BizTalk Server 2013 Deep Dive classes.

1 I say “nicely” succinct due to one of my college professors constantly saying of essays written by Freshmen: “Brevity is a virtue”.

Our first TFS2012 ADMIN COURSE IN LONDON SCORES 96%

London_XSmallQuickLearn’s first TFS 2012 Configuration and Administration course to run in London has just finished and we’re happy to announce that the course scored a staggering 96% customer satisfaction rating based on the course evaluations. Our trainer also scored a perfect score of 100% for both his knowledge of TFS and his presentation ability.

Our next round of TFS 2012 courses in London includes the following courses.

  • Aug 19/20 – Managing Projects with TFS 2012
  • Aug 21/22 – Software Testing with Visual Studio 2012
  • Aug 23 – Test automation using Coded UI Tests in Visual Studio 2012

Our courses are run in London (Shoreditch EC2) but you can attend remotely from anywhere in the UK, Europe or Africa due to friendly time zones. Keen to find out more?

Windows Azure Service Bus Queues + BizTalk = Out of Body Experiences

This post is the third in a weekly series that will highlight things that you need to know about new features in BizTalk Server 2013. One of the major new features of BizTalk Server 2013, is the native ability to integrate with Windows Azure Service Bus through the new SB-Messaging adapter. This week we will be covering what can happen if you’re trying to integrate with applications that are loading up your Windows Azure Service Bus Queues with Brokered Messages made purely of properties.

Out of Context

Context properties are not a foreign concept to BizTalk developers. Indeed, BizTalk messages themselves are made up of both a message context and body parts. The same is true to some extent of Service Bus Brokered Messages – though the implementation differs greatly.

To deal with context properties of Service Bus Messages, the SB-Messaging adapter provides us the ability to promote these properties to the context of the BizTalk message generated upon receipt of a Brokered Message. The adapter configuration that controls this behavior looks like this:

sb-promote-props

One major difference between the properties of a Brokered Message and the context properties of a BizTalk message, is that BizTalk message context properties have a namespace to disambiguate properties that share the same name. Brokered messages have no such thing, and no concept of a property schema for that matter (which allows BizTalk to have an awareness of all possible properties that can exist in the context).

The adapter configuration setting pictured above is a bridge between those worlds that allows the Brokered Messages properties to be understood by BizTalk Server. Of course, you will have to define a property schema for those properties on the BizTalk side. Here’s an example of a really simple one that defines two custom properties:

propertyschema

All of this will function pretty perfectly – assuming that the message sent to the Queue has a body.

Out of Body

At last year’s TechEd NA conference in Orlando, one of the presenters (I believe it was Clemens Vasters) was discussing what Brokered Messages were, and how they were exchanged. In the talk, he mentioned that it was perfectly fine, and even preferable in some cases, to create a Brokered Message that was purely properties without any body content. Certainly this was a light-weight operation that relied only on HTTP headers, and required no overhead for serialization of body content. And at the time, I accepted this, and was happy.

As a result, a lot of my code interacting with the Service Bus involved snippets like this:

var client = Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(connString, queueName);
var message = new Microsoft.ServiceBus.Messaging.BrokeredMessage();
message.Properties.Add("CustomProperty", "Value");
message.Properties.Add("CustomProperty2", "Value2");
client.Send(message);

Notice here, we’re just passing around properties, and not dealing with a message body. That’s fine when I’m receiving the message in .NET code living somewhere else, but when moving into the BizTalk world, it became problematic. When attempting to receive such a message (even with the property schema deployed, and everything else otherwise happy), I would receive this (using the PassThruReceive pipeline):

errormsg

For those trying to use Google-fu to solve the same problem, the error message reads:

“There was a failure executing the receive pipeline: ‘Microsoft.BizTalk.DefaultPipelines.PassThruReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “Pipeline” Receive Port: “WontMatchWhatYouHaveAnyway” URI: “sb://namespacehere-ns.servicebus.windows.net/somequeuenamehere” Reason: The Messaging Engine encountered an error whlie reading the message stream.

If you came to this article because this error message appeared, and you’re not trying to receive an empty message from Azure Service Bus, just head right back to the Bing results page, and check the next result. Everyone else, stick with me.

Let’s take a step back for a second. BizTalk Server 2013 is designed for integration between systems. I typically should not be adjusting my behavior outside of BizTalk to work with BizTalk. So here I want to take the same approach.

What are our options here? Well clearly we have a failure in the pipeline while processing an entirely empty message body, which doesn’t allow us to get the point where we are processing a map. That removes our ability to use the excellent ContextAccessor functoid to pull the properties into the body of the message upon receipt.

Instead we are left with building a custom solution.

PropertyMessageDecoder Pipeline component

What is this custom solution I speak of? For now, I’m calling it the PropertyMessageDecoder pipeline component. It is a custom pipeline component that creates a message body based on the context properties of a BizTalk message. If you already have a message body, this pipeline component will not help you, since it blindly overwrites the body if one exists. Instead, this is a purpose-built pipeline component for the specific scenario addressed by this blog post.

I started development of this component by using Martijn Hoogendoorn’s BizTalk Server Pipeline Component Wizard. Unfortunately, it hasn’t yet been updated to work with BizTalk Server 2013, so I had to first create/upload a patch for BizTalk 2013.

Once I was able to create a custom pipeline component project, I created a simple pipeline component that took the input message, and dumped the context properties into the message bodies. I also included some configurable properties that allowed one to opt-out of properties from the BizTalk system properties namespace, or to filter out all properties except those from a specific namespace (especially helpful in this scenario).

Here’s the bulk of the Execute method for that component:

public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
    Stream dataStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);
    pc.ResourceTracker.AddResource(dataStream);

    using (XmlWriter writer = XmlWriter.Create(dataStream))
    {
        // Start creating the message body
        writer.WriteStartDocument();
        writer.WriteStartElement("ns0", ROOT_NODE_NAME, TARGET_NAMESPACE);

        for (int i = 0; i < inmsg.Context.CountProperties; i++)
        {
            // Read in current property information
            string propName = null;
            string propNamespace = null;
            object propValue = inmsg.Context.ReadAt(i, out propName, out propNamespace);

            // Skip properties that we don't care about due to configuration (default is to allow all properties)
            if (ExcludeSystemProperties && propNamespace == SYSTEM_NAMESPACE) continue;
            if (!String.IsNullOrWhiteSpace(CustomPropertyNamespace)
                    && propNamespace != CustomPropertyNamespace) continue;

            // Create Property element
            writer.WriteStartElement(PROPERTY_NODE_NAME);

            // Create attributes on Property element
            writer.WriteStartAttribute(NAMESPACE_ATTRIBUTE);
            writer.WriteString(propNamespace);
            writer.WriteEndAttribute();

            writer.WriteStartAttribute(NAME_ATTRIBUTE);
            writer.WriteString(propName);
            writer.WriteEndAttribute();

            // Write value inside property element
            writer.WriteString(Convert.ToString(propValue));
            writer.WriteEndElement();
        }

        // Finish out the message
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();

    }

    dataStream.Seek(0, SeekOrigin.Begin);
    var outmsg = Utility.CloneMessage(inmsg, pc);
    outmsg.BodyPart.Data = dataStream;

    return outmsg;
} 

The output will end up conforming to this schema:

propertymessageschema

And will look a little something like this:

<?xml version="1.0" encoding="utf-8"?>
    <ns0:PropertyMessage xmlns:ns0="http://schemas.quicklearn.com/PropertyMessage/2013/06/">
        <Property Namespace="http://schemas.example.org/" Name="CustomProperty1">Value1</Property>
        <Property Namespace="http://schemas.example.org/" Name="CustomProperty2">Value2</Property>
    </ns0:PropertyMessage>

When included in a pipeline alongside the XML disassembler component, we are finally able to take those pesky “empty” messages from Azure Service Bus and process them as XML documents. The message context properties are still retained in the context for routing, but our custom properties are also made available for use directly in maps (through the liberal use of Value Mapping (Flattening) and Logical functoids), and further processing.

To follow this through to the end, I created a quick proof-of-concept map:

samplemap

Essentially we’re looping through the properties from the context (hence using the Value mapping flattening functoid) and only mapping the value stored inside the Property node whenever the namespace and name of the property match those that we care about. Since the namespace for all of our custom properties is the same, we have a single Equals functoid that we’re sharing across all (two) properties.

After processing a message all the way through the bus, custom pipeline, and map, this should result in this beauty as opposed to a nasty error message:

sampleoutput

un-Borked brokered messages

Remember, that none of this stuff is necessary if you’re working with Brokered Messages that have a message body. You only need to go this deep when you’re dealing with Brokered Messages made purely of properties (which is a recommended practice when possible).

By bringing out-of-the-box first class support for Windows Azure Service Bus Queues, BizTalk Server 2013 continues to prove that with a solid and extensible architecture in place, any type of integration can be made possible.

If you would like to learn more about extending BizTalk Server 2013 to meet your integration challenges, check out one of our upcoming BizTalk 2013 Developer Deep Dive classes.

If you would like to access sample code for this blog post, you can find it on github.

Acknowledging a Subtle Change in BizTalk Server 2013

This post is the second in a weekly series that will highlight things that you will need to know about new features in BizTalk Server 2013. This week, we will examine a subtle change that didn’t even make the new features list, but could change the way you configure your X12 integration solutions.

Many of you who had previously downloaded and installed BizTalk Server 2010 CU3 did so to take advantage of a nice new feature in that CU — namely the ability to Generate 999 acknowledgements (in place of the already generated 997’s). The process for generating 999’s with CU3 was not necessarily intuitive, and somewhat limiting. It involved creating a custom pipeline with the EDI disassembler and toggling the Use 999 Acknowledgement instead of 997 property (that only shows up in the pipeline designer) to True.

999_pipelinecomponentsetting

While this was a huge improvement over some of the quickly hacked together solutions that had sprung up to tackle this challenge in the meantime, it was still lacking.

What if I already had lots of different semi-customized pipelines that needed this change? What if I want to use the same receive location to receive messages from multiple parties that will each have unique requirements for the types of acknowledgements they receive? Then I had some challenges ahead of me that were pretty boring at best, and/or unhappy and non-trivial at worst.

In the end, the setting of using a 999 (as opposed to a 997) wasn’t really tied to a particular agreement or business profile, and it required custom development to implement. Both of which, could have been better.

The New Way to 999

BizTalk Server 2013 introduces a new way to configure this, while allowing us to use out of the box components and update the setting at the agreement level. Just head over to where you would typically opt-in to generating a 997, and you will find this lovely drop-down list:

999agreement

Another thing that you will notice in the list, is that it lists both the 4010 and 5010 versions of the 997 as well. As one might expect, these same selections are also available to be configured at the Business Profile level as well.

Worth it

This is definitely welcome change, that will hopefully serve to prevent the spread of developer heartburn. Not only does this make an existing feature (since 2010 CU3) more visible, it also makes it more flexible and eliminates the requirement for custom development / deployment. This change alone – which didn’t even make the list of new features – may make it worthwhile to upgrade (depending on the complexity of your existing and upcoming X12 integrations).

Starting the Journey

If you’re just now starting the journey using BizTalk Server to tackle your X12 or EDIFACT integrations, and need a place to start, be sure to check out QuickLearn Training’s BizTalk Expert Series: EDI class. If you’re new to the BizTalk world, you have some time before the next EDI class to get into our BizTalk 2013 Developer Immersion class, which will take you from 0 to creating enterprise-scale integrations in 5 action-packed days.

What the BizTalk Server 2013 Mapper Updates Mean for You

This blog post represents the first in a weekly series that will highlight things you need to know about new features in BizTalk Server 2013. This week we will look at the new mapping engine and how the underlying changes in the engine might effect the behavior you see when using the BizTalk Mapper.

If you look at the list linked above, you find this:

The Mapper uses the XSLCompiledTransform class. Previous BizTalk Server versions used the XslTransform class, which is obsolete. The XSLCompiledTransform class provides performance enhancements, including:

  • Once the Load method completes successfully, the Transform method can be called simultaneously from multiple threads.
  • The new XSLT processor compiles the XSLT style sheet to a common intermediate format. Once the style sheet is compiled, it can be cached and reused.

For more information on the XSLCompiledTransform class, go to XslCompiledTransform Class.

The mapper now uses the XslCompiledTransform class, a class which was the result of a redesign of the XSLT architecture in the Visual Studio 2005 release (.NET 2.0 timeframe).  While load time of a transform using this class can be longer (since the transform must be compiled upon load), if cached it can yield a 4-fold performance improvement for transforms. Will we see this same level of improvement when used within the context of a BizTalk map? Not quite, but it will definitely be noticeable.

There is a fairly detailed blog post on the XslCompiledTransform class from the XmlTeam written around that time as well. I’m not going to re-hash all of that content here, though you should definitely take a look at the table under the Discretionary Behaviors heading. That table will unveil some things (read: strange edge cases) that used to “just work”, but will now cause exceptions.

Instead of focusing on performance improvement or weird edge cases, in this post, I wanted to look at something a little more common. It surfaced for our team as we were migrating some custom functoids from BizTalk Server 2010 to BizTalk Server 2013. Essentially what we found was that if you attempted to return a null value from a custom functoid, you would receive this error message:

ErrorFunctoidException

For the benefit of those using Google-fu to attack the same problem, the exception message reads: “Extension functions cannot return null values.”

Really this exception would occur regardless of using a custom functoid. Indeed, you can re-create the same behavior with a Scripting functoid returning null out of an inline C# method.

How to Return Null

This all begs the question, how am I supposed to return null? Well there are a few different cases to consider.

If you’re returning null because it’s cleaner than an empty string, but empty string is not considered a special value on its own, then it’s fairly simple. Toss a null coalescing operator between whatever value might be null and string.Empty. That was the fix that handled our case nicely:

 public string GetError(string lookupId)<br>{<br>return CachedDatabaseAccess.GetError(new Guid(lookupId)) ?? string.Empty;<br>} 

While that will cause the desired result in the destination message in this case, if I wanted to output null to the destination message I have a few choices still. I can still return string.Empty which will create an empty node in the document, use one of the Logical functoids to prevent a node from being created when it does not return true, or use the Nil Value functoid to set set the output as nil (assuming the destination schema allows it).

Passing Null Around

But what if I’m returning that null value so that it can be passed to another functoid? If both are scripting functoids and they’re both using inline script, I can do this quite easily by making use of a global variable within the map (in the screenshots below it is named result1), and then writing my code to access that in order to request the raw result.

NOTE: This is also a pattern we encourage for maintaining the state of .NET objects through chained functoids (since if they are returned directly the ToString method is called)

scriptfunc1

scriptfunc2

That’s all fine and good when things are inline C#, but what if I’m wanting to pass an earlier null value as an input to an external assemblies? Well that’s where things get a little bit trickier. Best bet there right now is to establish a special non-null value that can represent null, and pass that to an external method that wraps a call to the method you actually want to call and translates that value. Either that, or write custom functoids that can share a set of ThreadStatic values and have one of them wrap the call to the external method (though that might be a little bit overkill).

Wrapping it Up

Even though I’ve spent my time talking about one small annoying aspect of upgrading, let me tell you it’s a worthwhile price to pay for the massive performance improvements you’re going to see.

If you want to see how that custom functoid turned out, and interact with it yourself, be sure to check out one of our upcoming BizTalk Server 2013 Developer Deep Dive courses!

See also:

BizTalk Server 2013 Road Show

During the month of May QuickLearn will be collaborating with Neudesic and BizTalk 360 to bring a special BizTalk 2013 Event to major cities across the US. Discover how to transform your business with BizTalk Server 2013.

This invitation only event is designed to help you:

  • Connect and automate your existing assets to maximize the value of your IT portfolio.
  • Increase agility and reduce your TCO by leveraging the cloud and hybrid-cloud.
  • Enhance productivity by bridging the gap between your datacenter and employees.
  • Deliver innovative applications and solutions that integrate with new and existing assets.
  • Extract, report, analyze, publish and share information company-wide, in real time.
  • Extend LOB applications securely beyond traditional network and business boundaries.

Get a Sneak Peek at BizTalk PaaS*
We’ll be sharing yet-to-be-released features of PaaS, so all guests who attend the Sneak Peek session will be required to sign a Confidentiality Agreement with Microsoft.

Reserve button

Newly updated tfs 2012 (Update 2) courses coming to the UK in june

QuickLearn is excited to be heading to the UK to deliver our leading courses on Microsoft Visual Studio Team Foundation Server. These courses have just been completely refreshed to  cover the latest features Microsoft have included in Update 2.

Here is a list of the TFS 2012.2 courses we’re running in June. These courses are confirmed to run and if you book soon you’ll still get early bird registration!

What’s more, we’re bring our Remote Classroom Instruction (RCI) solution with us so you can attend our courses online from anywhere in the UK and nearby time zones!

Attend our TFS courses from any of these time zones

London_TZ

Courses will run from 9:30am to 5:00pm GMT (London time). Please consider this when booking.

BizTalk Server 2013 RTM

QuickLearn is very excited to share the news that BizTalk Server 2013 is now available for download on MSDN. The eighth release of BizTalk Server has been much anticipated and promises to be the next step in the on-going investments in BizTalk. In the near future, we can look forward to announcements that include Infrastructure as a Service (IaaS) capabilities as well as Platform as a Service (PaaS) capabilities. Read the blog from the BizTalk Team and download the new bits.

For the on-premises BizTalk Server 2013 release, Microsoft has focused on the following themes:

  • Improved Performance
  • Simplified Development and Management Experience
  • Cloud Connectivity
  • Running BizTalk Server in the cloud (IaaS)
  • Support for the latest platform and standards

Rob Callaway released a blog about his favorite features in BizTalk 2013. Behind the scenes, we have been working tirelessly to update our courses to BizTalk Server 2013. You can look forward to QuickLearn’s BizTalk Server 2013 training calendar coming soon!

If you haven’t already filled out the BizTalk 2013 Survey (or your answers have changed), check it out!

TFS 2012 Pre-conference workshop at tech-ed 2013

I received some great news a little while ago that I have been selected to present a one day pre-conference workshop at TechEd 2013 in both North America (New Orleans) and Europe (Madrid).

If you’re planning on attending TechEd this year, why not head in a day early and get some great hands on experience using Microsoft Team Foundation Server 2012. The breakout sessions and keynotes are always great but for many, a day spent getting hands-on with Microsoft’s ALM platform might be just what you need.

The pre-conference workshop I am delivering is titled “Kickstart Your Application Lifecycle Management Using Team Foundation Server 2012”. I’ve included the session abstract a the bottom of this blog post.

To attend one of the pre-conference workshop, simply choose one of the registration options that includes a pre-conference seminar. Eg.  “Early Bird Pricing + Pre-Conference Seminar”. Even if you’re not attending the full conference, you can attend the pre-conference seminar by itself. [More information]

QuickLearn’s BizTalk instructors have also submitted breakout session proposals and hopefully we’ll have some good news to share on that front in the next week or so.

SESSION ABSTRACT

Frequently Microsoft Team Foundation Server (TFS) finds its way into organizations through well intentioned developers taking it upon themselves to install and configure it. Unfortunately this usually leads to a very ad-hoc usage of the product that fails to deliver the real benefits of an integrated Application Lifecycle Management suite.

In this workshop we start by setting ourselves up with a brand new Team Project on TFS 2012 and then proceed to configure everything required to get our team ready for their first iteration.

This pre-conference workshop is designed to help attendees learn how to get projects started using Microsoft Team Foundation Server. The range of topics covered in this level 200 workshop have been selected to ensure attendees cover the primary areas of value in the product.

Attendees to the workshop receive workshop notes in electronic format which including the hands-on lab exercises, as well as a comprehensive list of resources that they can use after the conference to get up to speed with TFS.

New TFS 2012 Test Automation, Web perf and loading test course

NEW COURSE ANNOUNCEMENT

QuickLearn is pleased to announce the addition of a brand new course to our list of TFS 2012 courses we currently offer. The new course is a two day course focusing on Test Automation (Coded UI Testing), Web Performance and Load Testing with Visual Studio 2012.

Here are just a few of the things covered in this course.

  • Describe the various testing capabilities in Visual Studio 2012
  • Create Coded UI Tests from action recordings and using the Coded UI Test Builder
  • Understand the structure of Coded UI Tests and edit the generated code
  • Bind Coded UI Tests to a variety of different data sources
  • Run automated tests in a number of environments
  • Upgrade existing web performance and load tests from Visual Studio 2010
  • Create and edit Web Performance Tests and analyse test results
  • Create and edit Load Tests and analyse test results
  • Configure an environment for executing Web Performance and Load Tests

This course is more technical than our existing testing course and attendees will spend much of their time working in Visual Studio 2012. While attendees won’t write any code from scratch, being able to read and understand VB or C# code is required to get the most from this course.

This new course joins our existing 2-day course “Software Testing with Visual Studio 2012” to provide excellent coverage of the testing features available in Visual Studio 2012.

Two Testing Courses

This new course has already been delivered successfully in overseas markets and is scheduled to run here in the US on the following dates over the next few months.

You can attend this training in-person in our Kirkland, WA office or you can attend remotely from your home or office using our remote classroom infrastructure.

Remember, QuickLearn has a no-cancellation policy so if you book on these courses, they will definitely run!