Append invoice list EDI message on outgoing batch - biztalk

One of our partners requires that a "summary" edi message is appended to any EDI invoice interchange (apparently known as "invoice list"). This message contains a reference that every individual invoice should have in an RFF segment, as well as the cummulated MOA values.
My question is: does BizTalk Server (in particular BizTalk 2009) provide a convenient way to append another EDI message to the outgoing EDI batch upon release? I cannot find anything on MSDN.
My current idea is to append it in the send pipeline of the port that will transmit the batch, but I really would like a more convenient way.

I'll put it this way, your Trading Partner has a rather unusual, perhaps unique, requirement that is itself inconvenient. So, sorry, there is no 'convenient' way to accomplish this in BizTalk, probably in any platform either.
Anyway, here's what I would do, or at least some things I would try.
Batch the Invoices normally, such as with the Batching Service.
Subscribe to the Batch with an Orchestration.
Map the Batch to the Summary, which ever transaction that is, but it has to be X12/EDIFACT.
Use a dual input Map to create the batch with the summary appended.
Send to Send Port with the EDI Assembler.
I'm thinking it would be easier to use a Custom Xslt for the appending Map. That would save you from having to create a Schema for the Batch message, which doesn't actually ship with BizTalk.
The Xslt itself would be pretty simple since you just copying the two Messages. FYI, the Batch Message Orchestration Type wold be Microsoft.XLANGs.BaseTypes.Any. You can't use XmlDocument as a Map source.

I had the same requirement once, but instead of one specific summary message, I needed to be able to have full control over the the order of the EDI messages in the batch.
This is how I solved this at the time: http://blog.codit.eu/post/2009/11/10/Outbound-EDI-batching-in-BizTalk-Server-2009.aspx
It does have some downsides, but it might be handy to know.

Related

Deliver messages in order based on xml content in BizTalk

I have a problem where I receive files from a third party via a website. These files come in order from the third-party and sit in a folder. Because of security constraints, I am not able to poll the directory directly via SMB but instead I have to fetch the files every 1 minute using SFTP. This creates a problem because the files that were delivered to me in-order are now all together in my receive location's folder. I need to deliver these files in the order they came to my send port.
I have thought of creating a separate program that would open the files and then copy them in order (based a segment called SequenceId in the XML) to a folder within the BizTalk server that is monitored by the receive location which would ensure the files are delivered in order. I would prefer not to introduce another failure point (the program) but I am not sure how I can do this with pure BizTalk.
You can do this with pure BizTalk (search for BizTalk resequencing), however you end up with a complex solution including a singleton Orchestrations and it is usually easier to use a database table.
First interface picks it up, and just insert the data into a table. Either as flat table if your message structure is flat, or as a one field with XML data and another field that contains your sequence number extracted from the payload.
Your second interface polls a stored procedure that looks if the next in sequence is available to be processed.
You will have to have considerations about what to do if a particular message for a sequence never arrives, do you send out an alert, or process the messages you do have after a preset delay.

How to retrieve filenames for a BizTalk Purchase Order

I am very much new to BizTalk Server, one of our clients want to know the filename of the purchase order given by them. Its already been processed in the system through BizTalk Server and the client has received the purchase order, but he wants to get the filename of that purchase order (or in short the whole file for that purchase order) as there was some issue with the cost.
How can I get it or what are the steps for doing it?
Note: I am new to BizTalk so not much experieced in asking questions related to it. But if you have any questions which I can answer, please feel free to ask.
If you want to get the received filename inside an Orchestration you need to use the message context property BTS.ReceivedFileName.
e.g.
FileName = MessageName(BTS.ReceivedFileName);
If you want to set the filename in a send port to the received filename (or rather to what is in BTS.ReceivedFilename as you can set it yourself) then you need to use one of the predefined send Macros, in this case %SourceFileName%
If you want to see the filename in the BizTalk administration console, then you need to look at the message context and look for the ReceivedFileName property.

Storing unparsed HL7 2.x messages into a sql database

We are recieving HL7 2.x using the BTAHL7 accelerator. I want to dump the raw HL7 message to a sql table, with some discrete data including control id and others. My receive location is using the BTAHL72XRecievePipeline component. Is it possible to subscribe to the raw message, instead of the parsed xml format?
You'll have to us a custom pipeline component, something like this: http://codebetter.com/jefflynch/2006/04/08/biztalk-server-2006-archive-pipeline-component/
You can retrieve the raw message as the first step in the pipeline.
The UltraPort MS SQL Schema Engine does exactly what you're looking for. That's all that it does, it's very fast and very good at it, and has free fully functional trial. It sets up in literally minutes and they've got really good customer service. If you call in they'll walk you through a 10-15 minute example of importing HL7 messages (and actually encourage you to use your own HL7 data if you have any). 10-15 minutes will answer 90% of any questions you might ever have and it includes downloading and installing the software.
Home Page: http://www.hermetechnz.com/EasyHL7/prod_sql.asp
Online Help: http://www.hermetechnz.com/Documentation/UltraPort/MSSQL/index.html
It stores both the unparsed HL7 message as well as breaking it into parsed data tables as well as (optionally) storing the unparsed SEGMENTS as individual rows.
Hope this helps.

BizTalk custom adaptor

I am not sure if I ask the right question, but this is the scenario I am trying to run:
Multiple files (XML and a few related files, "attachments") have to get into BizTalk as a single message. I have looked into existing adapters, and don't see that done with existing once. To be more accurate, files are taken from file system. Files are not found at the same time, but arrive one at a time, when order is not ensured. XML (content) file is the one that knows what attachments it has to have (what other files).
We are looking into BizTalk 2009 and I was wondering would be that responsibility of a custom Adaptor, or something else. And were I could look for samples.
Thanks.
It is probably possible to do what you want using a custom adapter, though I'd recommend against it. You can achieve what you require using orchestration.
What you are looking for is likey a convoy, or at the least some use of correlation.
In BizTalk a convoy is a messaging pattern (as opposed a BizTalk feature) that allows groups of messages to be processed by a single orchestration.
You essentially use correlation on a receive port to group messages together in either a parallel (what you probably want) or sequential fashion.
There is an article [here](http://msdn.microsoft.com/en-us/library/ms942189(BTS.10\).aspx) by Stephen W. Thomas about convoys (it is for BT 2004 but the concepts still hold) and there is a lot of additional information on the web and in books (Professional BizTalk server 2006 has a subsection on them)
Without more details on your scenario it is hard to know exactly how the convoy would be built but below are two approaches to look at (also, I've not had a chance to properly use BT2009 so there may be extended support for correlation scenarios that help you out).
Flexible Correlation
If you don't know anything about the files listed in the context XML you will probably need a pattern like the one described by Charles Young in this post.
Non-uniform sequential convoy
If you do have a little bit of info before hand one way might be as follows (basically a Non-uniform sequential convoy):
This makes the assumption that there is some way of linking all the files together so you can correlate them.
Create a single orchestration that subscribes to you inbound receive port (which contains the file receive location).
This orchestration will have a single activation receive shape that is set up for your content file.
Once the orchestration is started by a content file a second correlated receive shape starts picking up the messages that match that content file. (this second receive could possible be in a loop to allow for variable numbers of files)
You then pack them all together into a single outbound file of your design and send them out once the full number of files has been received.
Seems to me a better approach would be to implement the above requirements with a combination of a custom pipeline component and/or a custom adapter. I assume you do not really need to manipulate the incoming files - except for the content XML file - or that you couldn't since they are in binary format. This calls for a custom pipeline component.
What you can do is develop a custom BizTalk adapter to interact with the file system and to implement the listening and looping logic. Next you can develop a custom pipeline component to create a single BizTalk message perhaps with base64 data type in it for binary data. Additionally you could also promote messages right in this component to enable orchestration subscriptions.
Orchestrations are more suited for implementing business work-flow scenarios where the messages are already in XML format. This do not appear to be the case. In any case I think at the very least a custom pipeline component would be needed.
David's answer is the correct answer.
Even in cases where you don't know absolutely nothing about the contents of the expected attachments, surely you know their names and locations. Therefore you can use the Flexible Correlation linked to in david's answer like this:
The key to the solution is to correlate on the builtin BTS.ReceivedFileName property.
First, create a custom receive pipeline, with a custom pipeline component that promotes the BTS.ReceivedFileName context property of the received messages. This simple custom component is fairly easy to write but you can make it straightforward by using third-party frameworks such as, (shameless plug, here) my PipelineComponentBase class or the excellent BizTalk Server Pipeline Component Wizard.
Now for the easy part:
Attachments are received in a specific location, designated by its path on the filesystem.
Create a receive location that listens to an alternate location, used only to control when files are actually swallowed by BizTalk.
In your orchestration, create a correlation type with the BTS.ReceivedFileName property and a correlation set base on this correlation type.
When you want to receive binary attachments, send a dummy message with the BTS.ReceivedFileName context property set to the filename of the binary attachment but with the path matching the alternate location ; the one used by the receive location. Initialize the correlation on the send shape.
Use an expression shape to copy the binary file from its original location to the one used by the receive location.
Finally, use a receive shape bound to the receive port that contains the receive location whose custom receive pipeline will promote the BTS.ReceivedFileName property.
Notice that you actually need to send a message in order to initialize the correlation. It does not matter what message you send actually. What I'd do is send the message through a send pipeline that contains an empty pipeline component. That is a pipeline component that reads the message but return null (so that the message vanishes into thin air before it reaches the adapter). A more elaborate solution would be to use a null adapter. That is an adapter that reads the message but does not do anything about it.
These two solutions avoid having many files accumulate in a temporary location somewhere, just for the sake of initializing a correlation!

Biztalk : can a message select an orchestration to be processed by?

Can a message select between an 'older' or 'latest' version of the orchestration he'd like to be prosessed by ?
thanks
If you're talking about the version fo the DLL in the GAC, I don't think this is possible. But if you maintain two seperate Orchestrations, you can use a promoted property to route the message to the appropriate orchestration. If it's more complicated than that, you can have a single receiving orchestration for themessage type and it can call the appropriate orchestration based on whatever criteria you can code into it. This is still the send port groups deciding which messages they want to run. Another approach would be Dynamic Send Ports. This really gives you the freedom to move direction of the message into the orchestration/app itself.
The Microsoft ESB 2.0 Guidance has some extensive thoughts on Itineraries which as I understand it, is the concept of the message containing specific processing steps on board. I am still digesting this, but it may be something to look at.

Resources