Geeks With Blogs
Bill Osuch - Random geek notes

Previously I talked about how to create a custom BizTalk pipeline component, and gave a few examples for accessing specific context properties. I wanted to be able to dump all the context properties to disk for examination, so I added a few lines of code and an on/off switch.

First, add two properties to your component:

private bool _EnableContextTrace;
private string _FileTraceLocation;

public bool EnableContextTrace
{
    get { return _EnableContextTrace; }
    set { _EnableContextTrace = value; }
}

public string FileTraceLocation
{
    get { return _FileTraceLocation; }
    set { _FileTraceLocation = value; }
}

Make sure to add them to the Load() and Save() methods in the IPersistPropertyBag region:

public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)
{
    object val = null;
    val = this.ReadPropertyBag(pb, "EnableContextTrace");
    if ((val != null))
        this._EnableContextTrace = ((bool)(val));
    val = this.ReadPropertyBag(pb, "FileTraceLocation");
    if ((val != null))
        this._FileTraceLocation = ((string)(val));
}

public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)
{
    this.WritePropertyBag(pb, "EnableContextTrace", this.EnableFileTrace);
    this.WritePropertyBag(pb, "FileTraceLocation", this.FileTraceLocation);
}

And finally add some code to the Execute method to loop through all the context properties and write them to a text file:

if (_EnableContextTrace && _FileTraceLocation.Length > 0)
{
    IBaseMessageContext contextList = inmsg.Context;
    string name;
    string nmspace;
    string contextItems = "";
    for (int x = 0; x < contextList.CountProperties; x++)
    {
        contextList.ReadAt(x, out name, out nmspace);
        string value = contextList.Read(name, nmspace).ToString();
        contextItems += "Name: " + name + " - " + "Namespace: " + nmspace + " - " + value + "\r\n";
    }

    using (StreamWriter outfile = new StreamWriter(_FileTraceLocation + "ContextProperties.txt"))
    {
        outfile.Write(contextItems);
    }
}

After building the DLL and adding it to the Pipeline Components directory, you should be able to configure the properties:

image

Deploy the project, drop and file in, and examine the contents of the ContextProperties.txt file that was created. In my case I ran a HIPAA 837 file through and got the following:

Name: FileCreationTime - Namespace: http://schemas.microsoft.com/BizTalk/2003/file-properties - 2/6/2012 7:41:01 PM
Name: ReceivedFileName - Namespace:
http://schemas.microsoft.com/BizTalk/2003/file-properties - C:\Temp\Split5010Claims\Input\0217_ACS_UIC_837P_OUT_20120203124952.edi
Name: ActivityIdentity - Namespace:
http://schemas.microsoft.com/BizTalk/2003/messagetracking-properties - {BDE71A7F-7351-480E-90A9-3607A92FAE2F}
Name: AdapterReceiveCompleteTime - Namespace:
http://schemas.microsoft.com/BizTalk/2003/messagetracking-properties - 2/6/2012 7:41:01 PM
Name: PortName - Namespace:
http://schemas.microsoft.com/BizTalk/2003/messagetracking-properties - Input5010_P
Name: InboundTransportLocation - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - C:\Temp\Split5010Claims\Input\*_837P_*.edi
Name: InterchangeID - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - {E0124062-FF6C-41B1-94F9-BDC929D54FC4}
Name: ReceiveInstanceID - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - {28D3080A-DE0F-48AC-AB08-C0B61285061F}
Name: ReceiveLocationName - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - Input5010_P_FILE
Name: ReceivePortID - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - {C4184808-467F-400F-9681-84924F44E9F4}
Name: ReceivePortName - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - Input5010_P
Name: AuthenticationRequiredOnReceivePort - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - False
Name: InboundTransportType - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - FILE
Name: LRPMsgBodyTracking - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - 0
Name: MessageExchangePattern - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - 1
Name: ReceivePipelineID - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - {45C53C6F-DBE9-49DB-AE7B-58A9D0901730}
Name: ReceivePortAuth - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - 0
Name: MessageType - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - http://schemas.microsoft.com/BizTalk/EDI/X12/2006#X12_00501_837_P
Name: SuspendMessageOnRoutingFailure - Namespace: http://schemas.microsoft.com/BizTalk/2003/system-properties - True
Name: ISA05 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 30
Name: ISA06 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 208876513
Name: ISA07 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 30
Name: ISA08 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 205498481UIC5
Name: ISA15 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - P
Name: ISA_Segment - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - ISA*##*##########*##*##########*30*123456789      *30*987654321UIC5  *120203*1249*U*00501*000000064*0*P*:~
Name: GS01 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - HC
Name: GS02 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 208876513
Name: GS03 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 205498481UIC5
Name: GS07 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - X
Name: GS08 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 005010X222A1
Name: ST01 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 837
Name: GS_Segment - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - GS*HC*123456789*987654321UIC5*20120203*1249*64*X*005010X222A1~
Name: ReuseEnvelope - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - False
Name: TsSequenceNumberInGroup - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 72
Name: GE01 - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 72
Name: AgreementPartIDOnReceive - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 0
Name: AgreementID - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - 0
Name: AgreementName - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - BTSGuestParty
Name: SenderPartyName - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - BTS-SENDER
Name: PartyName - Namespace:
http://schemas.microsoft.com/BizTalk/2003/messagetracking-properties - BTSGuestParty
Name: SourcePartyID - Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties - s-1-5-7
Name: ReceiverPartyName - Namespace:
http://schemas.microsoft.com/Edi/PropertySchema - RECEIVE-PARTNER

Technorati Tags:

Posted on Monday, February 6, 2012 2:06 PM BizTalk | Back to top


Comments on this post: Accessing all context properties in a custom BizTalk pipeline component

# re: Accessing all context properties in a custom BizTalk pipeline component
Requesting Gravatar...
Thank you for these great Biztalk topics and samples!
Left by jeca on Oct 16, 2013 4:10 PM

# re: Accessing all context properties in a custom BizTalk pipeline component
Requesting Gravatar...
Thanks for showing the path!
Left by joka on May 28, 2015 5:36 AM

Your comment:
 (will show your gravatar)


Copyright © Bill Osuch | Powered by: GeeksWithBlogs.net