Carolina Code Camp

Recently I gave a presentation on BizTalk Server 2009 at the Carolina Code Camp. The presentation covered the basics of BizTalk as well as the new features of BizTalk Server 2009.

I showed a short demonstration of a sample Purchase Order process. The components used were the Schema Designer, the Mapper, the Orchestration Designer, and the Consume WCF Service Wizard.

PowerPoint slides and demo code are available upon request.

REST Services in BizTalk

After many hours of research and blog reading, I came to the conclusion that there is no out-of-the-box or additional download (from an Adapter Pack or similar) support for REST services in BizTalk 2009. My recommendation is to have a C# helper class make the call for you. This is not what I was hoping to discover, although it does make sense.

REST services do not employ formal contracts, while BizTalk relies heavily on strong-typing of messages, these two philosophies contradict.

The other issue is that BizTalk needs two pieces of data for message delivery, destination URI and the Message. REST embeds the message as part of the URI. Again, this is a contradiction in philosophies.

We can create a Dynamic Send port with the correct URI (message embedding included), however BizTalk must send a message along with the URI and REST services reject this additional payload. Also, Dynamic Send ports do not support two-way communication so there is no way to correlate the response message, even if we were to actually be able to get one from the REST Service.

Until Microsoft adds support for REST in BizTalk, the workaround is to use a .NET Helper Method to make the REST call for us.

BizTalk Benchmark Wizard Released

One of the most common questions I get asked when looking at a BizTalk server project is what type of hardware is required and how many servers are needed.

This is often a black art.

Microsoft has stepped in to help with the release of a BizTalk Benchmark Wizard:

http://msdn.microsoft.com/en-us/biztalk/ee946766.aspx

Basically this tool is intended to work along side the BizTalk Server 2009 Scale-Out Testing Study:

http://msdn.microsoft.com/en-us/library/ee377068(BTS.10).aspx

Comparing the results of the study to your own running production environment can provide valuable insight into the performance of a BizTalk server farm and point to places where optimization is needed

BizTalk 2009 and SQL 2008 - Simple recovery mode breaks agent

I learned something today about SQL 2008 and BizTalk's SQL agent jobs. You must leave all BizTalk databases recovery model to "Full". I encounted a database set with the recovery model that was changed to "Simple" and it caused the agent's jobs to fail.

The reason for this is that "TRUNCATE_ONLY" has been deprecated for SQL Server 2008. This flag forces you to keep the recovery model as full. When I changed it back everything began funtioning normally again.

How to solve "Unable to determine if the owner has server access" error

This error message popped up all of a sudden during a load test with heavy volume.

Turns out to be a well known culprit to lots of BizTalk errors: the SQL Agent jobs were not running. Since we had just deployed to a test environment, and it was a new server, I didn't check to the Agent to see if it was running.

When I teach the class, I always mention this check, so I didn't follow my own advice. Anyway, the database server logs grew wildly and caused a shutdown.

When I configured and ran the jobs everything was fine, but it took a while for everything to complete.

Using a Flat File Schema to Consume Non-Xml Messages With No Type

Recently, a client was updating their message processing system from a collection of old VB6 applications to a BizTalk Server 2009 solution. One of the processes that they struggled with was updating their “special case” partners. I call these partners “special case” because they could not or would not adhere to the standardized schema for acknowledgment messages that was provided.

Each “special case” partner had their own message type, which changed without notice. The only thing that each had in common was that they agreed to put an acknowledgment bit somewhere within their return message. The placement of this acknowledgment bit was establish many years ago when the VB6 applications where written. The problem of extracting the bit was solved within the VB6 applications and the code was simply updated to C# to leverage the existing solution.

The other issue that was occurring is that each acknowledgment message had a different format, and non of them were valid XML. Most of the acknowledgments were actually screen scrapes from HTML pages with multiple root nodes and the message stuffed in at various places. BizTalk does not like to consume messages that have no schema/message type. To solve this issue, I had the client run the Flat File Schema Wizard to generate a Flat File Message with a single node and the entire contents of the message as its value (contained within CDATA markup to prevent corruption). The trick with this approach is the delimiter used to define the records. Since we only ever want one record, we need to choose a delimiter that has a very, very low probability of showing up in the incoming message. The delimiter I chose to use was “|abcdefghijklmnopqrstuvwxyz|”.

Now that the message was being consumed, it was a simple matter to use xpath to extract the string payload of the message and send it over to the existing C# helpers that know how to process it.

Where Do I Create a Web Reference in BizTalk 2009?

If you are reading this, most likely you were just as stumped as I was when I tried to create my first web reference in BizTalk 2009.

I assumed "Web Reference" was renamed to "Service Reference" but I quickly realized that something was wrong when I tried to create a message within an orchestration and had nothing listed within the "Web Message Types" section.

Well, to create a traditional Web Reference in BizTalk 2009 you have to take an extra step:

Right click on the project, and select "Add Service Reference" just as you did before, but this time, at the bottom click "Advanced". At the bottom of that screen click "Add Web Reference" which will take you to the web reference screen we recognize from previous BizTalk versions.

How to get to the packaged EDI schemas

I needed to validate a clients test message against the standard EDI schema for an X12 810 message but did an extensive search and was not able to find the schema for the message.

I found the EDI base DLL that contains the schemas (Microsft.BizTalk.EDI.BaseArtifacts.dll) but this didn't give me the ability to validate against the schema.

Turns out that all of the EDI XSD schemas are packaged in an exe located in: \Program Files\Microsoft BizTalk Server 2006\XSD_Schema\EDI. Just unpack the file named MicrosoftEdiXSDTemplates.exe and you will have extractions for all of the EDI schemas for EANCOM, EDIFACT, HIPPA and X12.

Be careful because this is a huge number of files. I opened the exe in win rar and just extracted the X12 files.

From there you can just add the schema to your project and validate your message

Mapping Unrelated Records

Introduction

I was recently asked to create a map to combine parent records with children records. The challenge was that the children records in the source document where not grouped with their parent record.

Mapping Unrelated Records

The message was similar to the following Xml where StatusItem is related by its ordinal position to DetailStatus/DetailItem. Look carefully at the message; the StatusItem parent node is SummaryStatus, which is at the same level in the Xml as DetailStatus. There is only one SummaryStatus node, and there are multiple DetailStatus nodes – all at the same level in the Xml.

<root>
  <
SummaryStatus>
    <
SummaryCode>102</SummaryCode>

    <
StatusItem>
      <
statusCode>item_0</statusCode>
    </
StatusItem>

    <
StatusItem>
      <
statusCode>item_1</statusCode>
    </
StatusItem>

    <
StatusItem>
      <
statusCode>item_2</statusCode>
    </
StatusItem>
  </
SummaryStatus>

  <
DetailStatus>
    <
DetailItem>
      <
statusCode>detail_0</statusCode>
    </
DetailItem>
  </
DetailStatus>

  <
DetailStatus/>
    <
DetailItem>
      <
statusCode>detail_1</statusCode>
    </
DetailItem>
  </
DetailStatus>

  <
DetailStatus/>
<
root>

In reality a message similar to the above is being provided by an outside source and we cannot modify it. By convention we are given the assumption that there is a DetailStatus record for each StatusItem, however there is not always a DetailItem. Our job is to map the output and combine the StatusItem code with its each DetailItem code.

The output goal is similar to the following Xml:

<root>
  <
SummaryCode>102</SummaryCode>

  <
StatusItem>
    <
StatusCode>item_0</StatusCode>
    <
DetailItem>
      <
StatusCode>detail_0</StatusCode>
    </
DetailItem>
  </
StatusItem>

  <
StatusItem>
    <
StatusCode>item_1</StatusCode>
    <
DetailItem>
      <
StatusCode>detail_1</StatusCode>
    </
DetailItem>
  </
StatusItem>

  <
StatusItem>
    <
StatusCode>item_2</StatusCode
  </StatusItem>
</
root>

The BizTalk map below works by using the Iteration Functoid comparing the position of the current SummaryStatus parent record to the position of the DetailStatus record. Additionally the Logical Existence Functoid is used so that if a DetailItem does not appear in the source message, then it won’t appear in the Target message.

MapParentToChild

External Links from MSDN

Previous Articles

Fix for BAM error "Views or Activites may be missing because one or more database(s) could not be contacted"

I had to migrate a BAM implementation into production from a development environment where everything in localized to a clustered database back end.

The deployment went fine, including the BAM part, but I couldn't access the views in the BAM portal. I verified that data was being written into the BAM database, but when I went to the portal to view the data I saw the following message:

Views or Activites may be missing because one or more database(s) could not be contacted. No view to display

There was also an error in the event log which read:

Referenced database 'BAMPrimaryImport' on server 'xxxx' is not accessible. The error is:
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.

After some investigation I learned that the owner of the BAMPrimaryImport database needed to be a domain account. I tried to change the account role:

sp_addrolemember 'dbowner' 'domain\user'

This failed with an error.

So I ran instead (which does not remove the user, just ‘resets’ the users access rights):

sp_revokedbaccess 'domain\user'

Which threw an error, but the account was holding the db owner schema, so I changed that to dbo and it worked.

Then, I could run the original call (which now worked):

sp_changedbowner 'domain\user'

The views are now visible in the portal, so if you see this error above, this may be the cause.