0

Many historical posts about BizTalk Context Accessor (CodePlex), but all links are broken. Is there a state-of-the-art context accessor functoid / component to be used today? Or, is there any other way like creating helper class or something like it?

My aim is to add file name (without path) into the destination message in a map using Custom XSLT. No existing orchestration, only picking up a file and running a map to transform message from source to destination format (that requires source file name added to it...).

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
JERKER
  • 907
  • 8
  • 17
  • 1
    There isn't one available out there on the internet. I do have a copy of that code that was upgraded and improved for BizTalk 2010, but it doesn't even compile in Visual Studio 2013 for BizTalk 2013R2. I could send you that code base if interested. An alternatives to the Context Accessor is the BRE Pipeline Component, where you can inject something into the payload for the map to be able to use. – Dijkgraaf Mar 29 '22 at 20:50
  • @Dijkgraaf, yes, I am interested in that code base (at least for my understanding of what it actually does). – JERKER Mar 30 '22 at 08:36
  • 1
    The context accesor for the incoming pipeline uses a two step approach. First pipeline component will store the 'Context' API (available in pipelines) in a 'Thread Local Storage' variable. It can be placed in any stage as long as its before the transform. The functiod will retrieve that value and thereby have access to the Context. Since the pipeline will run within one Thread (at least till BT 2016). – Marvin Smit Mar 30 '22 at 12:31
  • 1
    @MarvinSmit Are you the author of the Context Accessor? I see your name in the header of the pipeline and functoids :-) If so would it be OK for me to post the code here? – Dijkgraaf Mar 30 '22 at 19:57
  • 1
    @Dijkgraaf I am the original author of that code. I used to teach for DevelopMentor (BizTalk being one of the courses I did) and gave it to any attendee who wanted it. So Yes, feel free to make the code available to developers. – Marvin Smit Mar 31 '22 at 11:04
  • 1
    @Dijkgraaf After searching through some old USB drives, I found the original code. It was written for BizTalk 2006. I've put it up on github https://github.com/MarkVinceSmit/BTContextAccessor for those interrested – Marvin Smit Oct 31 '22 at 09:40

2 Answers2

1

I solved my problem (this time) using an orchestration where I can access the context of the incoming message easily, and after mapping, inject/update the outgoing message with the file name.

I had one additional problem to solve that helped me accept using orchestration as solution this time. Two flies in one stroke.

(Problem was - note to self - I wanted to reuse destination schema in another debatching scenario, i.e. it was a envelope schema. Funny thing, BizTalk was not able to resolve body content schema if map was run in receive port. However, running map inside an orchestration, it was able to resolve the body content schema and mapping to envelope schema as destination worked.)

JERKER
  • 907
  • 8
  • 17
0

An alternative to the Context Accessor functiod is to use the BRE Pipeline Framework, and read the context property and inject it into the XML Payload.

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54