Andy's profileAndy's WarholeBlogLists Tools Help

Andy's Warhole

Andy Mater

Occupation
Location
No list items have been added yet.

Flat File Disassembler

While I was developing a flat file disassembler flat file component to handle multiple flat file formats, I was completely brought off track by something I found on Gilles’ Weblog: ‘In a pipeline component, some streams are not seekable: Improvements to the Archiver’.

The confusing text was:

I should have used BodyPart.Data which in the case of custom pipeline components makes a copy of the inbound message:
// Get a *copy* of the original input stream
originalStrm = bodyPart.Data;

However, when testing my pipeline component the messages seemed to disappear. The message types were determined correctly, the document specification name was determined correctly, but my message did not appear in the output location. After a lot of frustration and time, it finally hit me; maybe the resulting stream was empty. I thought, because of the comment mentioned above, that I was dealing with a copy of the stream, but according to the MSDN:

In custom pipeline components, Data clones an inbound data stream, whereas GetOriginalDataStream returns the original inbound stream.

So, instead of dealing with a copy I was dealing with a clone of the stream. Adding the following lines solved the problem, pffff:

// Preserve the stream position
long position = dataStream.Position;

// Restore the stream position
dataStream.Position = position;

Failed to access IIS metabase

Technorati Tags: ,

Recently I was working with WCF and ran into the following error:

Server Error in ‘/WCFService’ Application

Failed to access IIS metabase.

The solution was simple. Executing the below statement solved the problem.

aspnet_regiis /i

The error indicates that the .NET Framework is not registered with IIS. The .NET Framework detects which versions of IIS exist when the .NET Framework is installed, and it automatically registers itself with IIS. If IIS does not exist when .NET Framework is installed, the .NET Framework is not registered with IIS.

The command with -i switch is used for installing ASP.NET and upgrading all application pools to ASP.NET version which came with the ASP.NET IIS Registration Tool. It will ignore the previous version of application pool.

See Microsoft: ASP.NET IIS Registration Tool (aspnet_regiis.exe).

The node to be inserted is from a different document context

 
Often, when I first try to copy a node from one XML document to another I get the following error:
The node to be inserted is from a different document context.
This time it was because I used InsertAfter() incorrectly.
svcNode.InsertAfter(statsNode, svcNode.SelectSingleNode("Type"));

When copying a node from one document to another you have to use ImportNode() and then add that node to the document.
svcNode.InsertAfter(xmlDocInst.ImportNode(statsNode, true), svcNode.SelectSingleNode("Type"));
 
I have to keep remembering this.

BizTalk mapping behaviours

When using the multiplication functoid in the BizTalk mapper I ran into some strange behaviour. In the source schema I had two elements: Price, defined as string, and NumberOfTransactions, also defined as string. I used the multiplication functoid the determine the TotalSalesAmount, again defined as string with restriction ^-?(\d{0,16})(\.\d{1,4})?$, in the destination schema.

The result surprised me; the price, 0.0340, multiplied by the transctions, 6, resulted in a total amount of 0.20400000000000002. Obviously, the result was not the result I wanted to see.

So, I tried using a custom scriptoid. The scriptoid contained the following functoin:

public Double ReturnTotalAmount(string p_noTxn, string p_prcRet)
{
    // Set to English-United Kingdom meaning period as a decimal
    // indicator and comma and thousand grouping delimiter
    IFormatProvider culture =
             new System.Globalization.CultureInfo("en-GB", true);
    System.Globalization.NumberStyles styles =
             System.Globalization.NumberStyles.AllowExponent |
             System.Globalization.NumberStyles.Number;
    long numTxn = Convert.ToInt64(p_noTxn);
    Double retailPrice = Double.Parse(p_prcRet, styles, culture);
    Double totalAmount =  numTxn * retailPrice;

    return totalAmount;
}

The result again did not meet my expectations. The total amount ended up being 0.20400000000000002. After being puzzled for a couple of minutes I found the answer. The above code needed just a little adjustment. The final code is:

public string ReturnTotalAmount(string p_noTxn, string p_prcRet)
{
    // Set to English-United Kingdom meaning period as a decimal
    // indicator and comma and thousand grouping delimiter
    IFormatProvider culture =
             new System.Globalization.CultureInfo("en-GB", true);
    System.Globalization.NumberStyles styles =
             System.Globalization.NumberStyles.AllowExponent |
             System.Globalization.NumberStyles.Number;
    long numTxn = Convert.ToInt64(p_noTxn);
    Double retailPrice = Double.Parse(p_prcRet, styles, culture);
    Double totalAmount =  numTxn * retailPrice;

    return totalAmount.ToString(culture);
}

I simply had to explicitly convert the result back into the right datatype, i.e. string, using the defined culture. Another valuable leason learned.

Macros in Send File Adapter

I always seem to forget the most common macros when using the Send File Adapter in BizTalk, so this is a reminder.

%datetime% Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss.
%datetime_bts2000% UTC date time in the format YYYYMMDDhhmmsss, where ss means seconds and the last s means hunderds milliseconds.
%datetime.tz% Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD.
%DestinationParty% Name of the destination party. The value comes from message the context property BTS.DestinationParty.
%DestinationPartyID% Identifier of the destination party (GUID). The value comes from the message context property BTS.DestinationPartyID.
%DestinationPartyQualifier% Qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.
%MessageID% Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.
%SourceFileName% Name of the file from where the File adapter read the message. The file name includes extension and excludes the file path. If the context property does not have a value, for example, if message was received on an adapter other than File adapter, then the macro will not be substituted and will remain in the file name as is.
%SourceParty% Name of the source party from which the File adapter received the message.
%SourcePartyID% Identifier of the source party (GUID). The value comes from the message context property BTS.SourcePartyID.
%SourcePartyQualifier% Qualifier of the source party from which the File adapter received the message.
%time% UTC time in the format hhmmss.
%time.tz% Local time plus time zone from GMT in the format hhmmssTZD.
 
No list items have been added yet.