PipelineTesting: XML Assembler and E_FAIL

PipelineTesting: XML Assembler and E_FAIL

Fellow BizTalk developer Bram Veldhoen was kind enough to send me some suggestions
for a future version of my PipelineTesting library,
as well as with a question that could point to a potential bug in the library.

The problem basically revolves around consuming a stream returned by the XML Assembler
component in a send pipeline when testing under a library. What Bram noticed was that
executing the pipeline would seem to work, but trying to read the body part stream
of the output message would fail with a ComException with error code 0x8004005
(E_FAIL)
.

I was fairly confident this should’ve been working, based on my own use of the library,
but I sat down to test it just to make sure. What I discovered was that indeed this
can happen if the pipeline context for the test is not aware of the schema for the
message being processed by the pipeline.

I added a new test to the library to make sure this was working correctly:

[Test]

public void CanReadXmlAssemblerStream() {

   SendPipelineWrapper pipeline = Pipelines.Xml.Send()

      .WithSpec<Schema3_FF>();

   IBaseMessage input = MessageHelper.CreateFromStream(

      DocLoader.LoadStream("CSV_XML_SendInput.xml")

      );

   IBaseMessage output = pipeline.Execute(input);

   Assert.IsNotNull(output);

   // doc should load fine

   XmlDocument doc = new XmlDocument();

   doc.Load(output.BodyPart.Data);

   XmlNodeList fields = doc.SelectNodes("//*[local-name()='Field3']");

   Assert.Greater(fields.Count, 0);

}

There are a few things to keep in mind about this issue:

  1. If you’re using the XML Assembler, make sure your pipeline context has all the necessary
    schemas. There are three ways you can do this, depending on how you are creating the
    pipeline:

    1. If you’re using the original raw API, you can use the AddDocSpec() method
      of the SendPipelineWrapper class.
    2. If you’re using the new, simple API, you can add the schema through the WithSpec() method,
      which is what the test above does.
    3. If you’re using the simple API, but you’re dynamically creating the pipeline, you
      can just add the schemas directly in the XmlAssembler configuration using the WithDocumentSpec() and WithEnvelopeSpec() methods
      (see the XmlAssembler.cs file for details).
  2. Make sure you’re testing the right thing. Sometimes, it’s enough to make sure that
    the pipeline can be executed successfully. Remember, however, that pipelines are streaming
    beasts, so a lot of the work will oftentimes happen just when you read the resulting
    stream, thus causing the processing to happen.

    This is exactly the scenario we’re seeing here today.

The second point is really important, but, for some reason, I never put much emphasis
in it when creating the library and when talking about it. I think this is important
enough to warrant doing something about it.

For starters, I’ve committed a few changes to the PipelineTesting
repository
. Besides adding the test above, I’ve also added a few ConsumeStream() and ReadString() helper
methods to the MessageHelper class to make it easier to validate your
components work by simply reading the entire stream from a message. I’ll add a few
other helper methods for this later on, but the idea is to make it so that you can
write less code for your tests.

technorati BizTalk, PipelineTesting

Working with Fault messages & BizTalk 2006 R2

A while ago I needed for several request/response orchestrations to create a fault message.

When an exception occurs in an orchestration it’ll timeout and won’t send a soap fault message. At least what you want to do is send a message that something went wrong. In my case I wanted to send the detailed exception as well.

I found several sources on the Internet but they weren’t all that complete.

My scenario works at least for the following scenario:
I have a request/response orchestration, hosted as WCF receiveport. All underlying webservices are WCF hosted services.

The Fault messaging howto

Btw, this howto assumes some basic knowledge of BizTalk 2006 R2 and WCF

  1. First your orchestration needs to be long running. This is due to the fact that the send port is encapsulated by an atomic scope.
  2. Create an scope were all ‘the magic’ happens. (see screenshot)
  3. Now create the exception handler.
    You can choose exception or in my case I choose SoapException.
  4. Now create your request/response port. When that’s done, give a sane name to the operation and right click to create a Fault message.
    You can choose to create a string as fault message or something else. But a different approach can also be very handy.
  5. Create you own custom fault contract within WCF, example code:
    [DataContract(Namespace = "http://mynamesapce/2008/08/Faults", Name = "OperationFault" )]
    public sealed class OperationFault
    {
        private string _message = String.Empty;
     
        /// <summary>
        /// Creates a new, uninitialized instance.
        /// </summary>
     
        public OperationFault()
        {
        }
     
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public OperationFault(string message)
        {
            _message = message;
        }
     
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public OperationFault(Exception error)
        {
            if (error != null)
            {
                _message = error.Message;
            }
        }
     
        /// <summary>
        /// Gets or Sets the message
        /// </summary>
        [DataMember]
        public string Message
        {
            get { return _message; }
            set { _message = value; }
        }
    }

  6. Create a message within the orchestration and choose the OperationFault class as your message.
  7. Assign the message to the Fault port.
  8. Now comes the part were we take a look at the exception scope handler. If we look at the scope exception handler below:

    This is the send share with the atomic scope around:

    So if the send did not succeed. (e.g. An exception occurred earlier). At the moment the exception raises we need to construct the Fault message.

    The code for the messageassignment looks like this:

    FaultMessage =

    new MyNamespace.FaultContracts.OperationFault(soapException.Message + soapException.StackTrace);

    Btw you can put any kind of message you like.

    The extra decide is necessary to let the orchestration/compiler believe that the send only executes if the other didn’t complete or didn’t start.

    The code for the decide:

    !succeeded(TransactionName)

  9. Now you’re done for the orchestration part!. So for a recap the complete orchestration (Sorry without the connected receive and send shapes.)
  10. If you make from the orchestration call to external webservices via WCF, don’t forget to NOT enable this setting:

    Propagate fault message.

    This options is used if you want to have separate handling of (typed)exceptions from a (wcf) webservice. Theirs only one disadvantage that you can’t handle generic soapexception quite easy.



  11. On the consumer side of the BizTalk orchestration you can use the OperationFault class to catch the exception.

Sources

I’ve to thank my former colleague: Fedor Haaker Together we implemented this kind of error handling. (Although he came up with operationfault solution.)

So big up for Fedor J

FrOSCon 2008

On very short notice I got aware of the Free and Open Source Software Conference (FrOSCon) in St. Augustin near Bonn/Germany. Unfortunately the program neglects open source projects in the .NET/Mono field. But it still looked interesting so I attended some talks there.
First day’s keynote speaker was Andrew S. Tannenbaum (his book on Distributed Systems […]

Screencast – Hosting WCF Services in ASP.NET/IIS

First of all, “Hi”!  As Cliff said, I’ve joined the Connected .NET Framework product management team here.  It’s been great so far, and we have lots of great content planned for WF/WCF dev centers.  But it’s been a couple of months now and after my short honeymoon period, I was told it’s time I blogged something.  This one is an easy spike (a little Olympic Beach Volleyball lingo), thanks to the great setup by Cliff and Aaron.  Of course I am talking about the great series of short How-To screencasts we are rolling out.  This is only the third week, but trust me, we are going to have one of these every week for a while and tons of great connected framework knowledge will be shared.


This week, for our third installment, CSD MVP Aaron Skonnard walks you through how to host WCF services in ASP.NET/IIS.


The WF/WCF screencasts are a weekly series of Channel9 videos done in conjunction with the folks at PluralSight to help developers new to WF/WCF see how the technology is used. Aaron and the PluralSight folks are now offering online training courses (in a format similar to these screencasts) as a compliment to their catalog of instructor-led training courses covering Microsoft connected systems technologies. Their training topics range from .NET v3.5 (including an excellent WF/WCF Double Feature course) to WSS to BizTalk server.

MSHUG HL7 Based Data Warehousing

Eric Washburn CTO Athena Advanced Technologies

Very interesting method to warehouse all data components to the warehouse. There is a separate table that defines all of the complex data types, but each segment has its own table.

There is a unique key in the segment to represent the complex data type that then ties the segment to the complex type.

I would write more about it, but I was too interested in seeing how everything was done.

MSHUG – HealthVault Architecture Overview

Sean Nolan – Chief Architect, Microsoft

Health Vault is like PayPal, they go to sites that use Health Vault to communicate data.

Why should you integrate with HealthVault:

Private and Secure Storage

Consistently log in using secure login

Application Interoperability – the ability to collect various data into one central repository

Device Connectivity – The ability for new devices to communicate directly to the health vault

Application and Device Discovery

Privacy and Security Focused – the customer is in control, the customer is in control of their own privacy

Industry Standards, it is an open platform, free and published SDK and APIs, (found on the HealthVault site) Community Promise, Easily Extensible Data Model, Strong Developer Community: MSDN Documentation

Modes:

Native: HealthVault is an online database

Copy: HealthVault is a synchronization resource to (imporpe cloyt/export/merge)

Per-type globalized transformation

  • html
  • tabular view
  • Standards and Device Exchange
  • Custom (custom xsl) on the Healthvault server ‘dime’

Custodianship – allows to permissions to be granted to people (children for example) that can be granted on a ‘sliding’ scale, eventually, you can give it up when they move away.

Online and Offline processing mode, grants access instantly, and only for that session, or a longer term if necessary

MSHUG – Edifects using BizTalk Solution for end-to-end HIPAA transaction processing

Herb Larsen Sr. Vice President of Alliances, Edifects Inc.

Not a lot of payors or providers have found that that ROI has been reached by implementing HIPAA.

A lot of the reasons is because the tasks of moving the edits from the back end system to the front end (BizTalk) is difficult.

Ramp Manager product – allows to test without being on the test without having to be on the phone with the other party and asking them to ‘submit’ the file and read back the errors.

Edifects XEngine – built on BizTalk Server 2006 R2

Because MS is not considered a covered entity, MS has not supplied a lot of HIPAA security standard documentation.

MSHUG Opening Keynote

The next conference will be on April 4th 2009 in Chicago.

Steve Aylward – General Manager Health and Life Sciences Microsoft

Watched the future of Microsoft in healthcare video.

Microsoft is making a huge investment in healthcare.

It took 4 releases (10 years) to outsell MSDOS

It took 9 releases (11 years) to become most popular word processor

It took 5 releases (10 years) to become the leading spreadsheet

$8 billion in R&D, a large (no numbers as far as percentage directed directly at Healthcare, but a large portion)

In 2000, MS had 63 employees dedicated to Healthcare.

Amalga – Health Information System – not available in the US. Designed for the emerging markets. (used to be called Global Care)

Amalga – Unified Intelligence System – not limited to caregivers, but can be customized to end users

HealthVault – Internet health platform that enables third parties to create applications to stored personalized health care information